Add browser - database schema browser using tuikit (curses UI). Add listdepends - tool which shows depending views for column. Update pgdatadiff - allow composite primary key. Update pgmanager - RowDict is now OrderedDict. Drop support for Python2.x.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import locale
locale.setlocale(locale.LC_ALL, '')
from tuikit import *
from pgtoolkit import pgbrowser
from pgtoolkit.toolbase import SimpleTool
class MyApplication(Application, SimpleTool):
def __init__(self):
Application.__init__(self)
SimpleTool.__init__(self, name='browser', desc='PostgreSQL database browser.')
self.init()
self.top.connect('keypress', self.globalkeypress)
browser = pgbrowser.PgBrowser(self.pgm.get_conn('target'))
model = TreeModel()
view = TreeView(model)
self.top.add(view)
# populate schemas
schemas = browser.list_schemas()
model.add('/', [schema['name'] for schema in schemas if not schema['system']])
# populate tables
for schema in schemas:
if schema['system']:
continue
tables = browser.list_tables(schema=schema['name'])
schemanode = '/'+schema['name']
model.add(schemanode, [table['name'] for table in tables])
view.collapse(schemanode)
vert = VerticalLayout()
self.top.layout(vert)
view.setfocus()
def globalkeypress(self, keyname, char):
if keyname == 'escape':
self.terminate()
if __name__ == '__main__':
app = MyApplication()
app.start()