#!/usr/bin/python # Copyright (C) 2009 Lars Wirzenius # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . '''Self-standing program to dump information about a Dimbola database.''' import sqlite3 import sys def dbinfo(filename): conn = sqlite3.connect(filename) c = conn.cursor() c.execute('select tbl_name, sql from sqlite_master where type="table"') tbl_names = [] for tbl_name, sql in c: tbl_names.append(tbl_name) print sql print for tbl_name in tbl_names: print 'table:', tbl_name c.execute('select * from %s' % tbl_name) print 'columns:', ' '.join(t[0] for t in c.description) for row in c: for col in row: print repr(col), print print def main(): for filename in sys.argv[1:]: dbinfo(filename) if __name__ == '__main__': main()