:date: 2018-09-10
==========================
Monday, September 10, 2018
==========================
Today I have still be documenting and tidying up before pushing my
work on the new accounting report.
More SQL summaries
==================
I had some work with :ref:`specs.tera.sql`. Since there is no more
virtual table `ledger.AccountingReport`, I thought Okay let's analyze
the SQL generated by
:meth:`lino_xl.lib.sheets.Report.run_update_plan`. Oops, our
:func:`lino.api.doctest.show_sql_summary` didn't yet swallow INSERT
INTO and DELETE FROM statements.
This is where I searched for "Python SQL parser" and found `sqlparse
`__.
>>> import sqlparse
>>> sql = "SELECT a, b, c FROM foo WHERE bar = 5;"
>>> parsed = sqlparse.parse(sql)
>>> for stmt in parsed:
... print(stmt)
SELECT a, b, c FROM foo WHERE bar = 5;
>>> stmt = parsed[0]
>>> print(stmt.get_type())
SELECT
>>> for token in stmt:
... print token.__class__, token
SELECT
a, b, c
FROM
foo
WHERE bar = 5;
>>> sql = "SELECT COUNT(*) AS __count FROM foo WHERE bar = 5;"
>>> parsed = sqlparse.parse(sql)
>>> stmt = parsed[0]
>>> for token in stmt:
... print token.__class__, token
Corporate-driven open source
============================
This reminds me Brett Cannon's blog post `Setting expectations for
open source participation
`__
where he writes "For a day job I am the dev lead for the `Python
extension for Visual Studio Code
`__. Originally
the extension was an `open source, personal project
`__, but then Microsoft
decided it would be a good idea to support the most popular extension
for VS Code, so we hired its creator (Don Jayamanne), put me on the
team, and then we re-launched the extension as an `official open
source project from Microsoft
`__ (and now we are a team
of four developers and a product manager). So I participate in what I
would call *corporate open source* for a living because even if we
never received a single outside contribution ever again, the
extension's development will continue thanks to Microsoft."