Source code:
from lino.apps.ledger.ledger_demo import startup from lino.reports import Report, RIGHT from lino.adamo.datatypes import INT class DatabaseOverview(Report): def __init__(self,dbsess): self.dbsess=dbsess Report.__init__(self) def setupRow(self,row): row.qry=self.dbsess.query(row.item._instanceClass) def getIterator(self): return self.dbsess.db.schema.getTableList() def setupReport(self): self.addVurtColumn( label="TableName", meth=lambda row: row.item.getTableName(), width=20) self.addVurtColumn( label="Count", meth=lambda row: len(row.qry), datatype=INT, width=5, halign=RIGHT ) self.addVurtColumn( label="First", meth=lambda row: unicode(row.qry[0]), when=lambda row: len(row.qry)>0, width=20) self.addVurtColumn( label="Last", meth=lambda row: unicode(row.qry[-1]), when=lambda row: len(row.qry)>0, width=20) sess = startup() rpt=DatabaseOverview(sess) rpt.show()
Output:
TableName |Count|First |Last --------------------+-----+--------------------+-------------------- Currencies | 4|EUR |EEK Products | 2|Chair |Table Journals | 1|outgoing invoices |outgoing invoices BankStatements | 0| | MiscOperations | 0| | Invoices | 1|OUT-1 |OUT-1 InvoiceLines | 2|ProductInvoiceLine(O|ProductInvoiceLine(O | |UT,1,1) |UT,1,2) BalanceItems | 0| | CashFlowItems | 0| | ProfitAndLossItems | 17|TULUD |Ärikasum (-kahjum) Accounts | 0| | Bookings | 0| | Languages | 5|English |Dutch Nations | 5|Estonia |United States of | | |America Cities | 26|Bruxelles (be) |Kohtla-Järve (ee) Organisations | 5|Kurtz & Büntig |Mets & puu OÜ Persons | 15|Andreas Arens |Hans Flott Functions | 3|Director |Sales representant Contacts | 19|Andreas Arens |Bäckerei Ausdemwald | | |(Anton Ausdemwald)
Refering articles:
- Converting races, ledger, examples (code changes 18.02.06) — commit 302 more