author | Radek Brich <radek.brich@devl.cz> |
Sun, 10 Mar 2013 16:14:53 +0100 | |
changeset 76 | 3a41b351b122 |
parent 52 | 26121a8fe78b |
child 104 | d8ff52a0390f |
permissions | -rwxr-xr-x |
52
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
""" |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
interactive schema browser |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
Connect to specified database and open interactive shell. |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
PgBrowser instance is "browser". |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
Example: |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
>>> browser.schemas['myschema'].tables['mytable'].columns['id'].default |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
"nextval('mytable_id_seq'::regclass)" |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
""" |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
from pgtoolkit import pgbrowser, toolbase |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
import code |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
class InteractiveBrowserTool(toolbase.SimpleTool): |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
def __init__(self): |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
toolbase.SimpleTool.__init__(self, name='ibrowser', desc='Interactive schema browser.') |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
self.init() |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
def main(self): |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
browser = pgbrowser.PgBrowser(self.pgm.get_conn('target')) |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
shell = code.InteractiveConsole(locals()) |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
shell.interact() |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
|
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
tool = InteractiveBrowserTool() |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
tool.main() |
26121a8fe78b
Update analyzeall tool: add REINDEX option. Add ibrowser tool (useful for PgBrowser testing). Fix PgBrowser.list_columns default value.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |