equal
deleted
inserted
replaced
|
1 #!/usr/bin/env python3 |
|
2 """ |
|
3 interactive schema browser |
|
4 |
|
5 Connect to specified database and open interactive shell. |
|
6 |
|
7 PgBrowser instance is "browser". |
|
8 |
|
9 Example: |
|
10 |
|
11 >>> browser.schemas['myschema'].tables['mytable'].columns['id'].default |
|
12 "nextval('mytable_id_seq'::regclass)" |
|
13 |
|
14 """ |
|
15 |
|
16 from pgtoolkit import pgbrowser, toolbase |
|
17 |
|
18 import code |
|
19 |
|
20 |
|
21 class InteractiveBrowserTool(toolbase.SimpleTool): |
|
22 def __init__(self): |
|
23 toolbase.SimpleTool.__init__(self, name='ibrowser', desc='Interactive schema browser.') |
|
24 self.init() |
|
25 |
|
26 def main(self): |
|
27 browser = pgbrowser.PgBrowser(self.pgm.get_conn('target')) |
|
28 shell = code.InteractiveConsole(locals()) |
|
29 shell.interact() |
|
30 |
|
31 |
|
32 tool = InteractiveBrowserTool() |
|
33 tool.main() |
|
34 |