author | Radek Brich <radek.brich@devl.cz> |
Tue, 07 Feb 2012 10:40:35 +0100 | |
changeset 27 | 5fb4883604d6 |
parent 16 | cb7e13711a99 |
child 44 | 4fe39c59c515 |
permissions | -rwxr-xr-x |
2 | 1 |
#!/usr/bin/env python3.2 |
2 |
||
9
2fcc8ef0b97d
Reorganize again :-) Add setup.py.
Radek Brich <radek.brich@devl.cz>
parents:
7
diff
changeset
|
3 |
from pgtoolkit import pgmanager, pgbrowser, pgdiff, toolbase |
2 | 4 |
|
5 |
||
7
685b20d2d3ab
Reorganize directories. PgDataDiff - reworked. PgManager - add fetchone_adapted, fetchall_adapted to cursor.
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
6 |
class SchemaDiffTool(toolbase.SrcDstTool): |
5 | 7 |
def __init__(self): |
7
685b20d2d3ab
Reorganize directories. PgDataDiff - reworked. PgManager - add fetchone_adapted, fetchall_adapted to cursor.
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
8 |
toolbase.SrcDstTool.__init__(self, name='schemadiff', desc='Database schema diff.') |
5 | 9 |
|
10 |
self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter') |
|
11 |
self.parser.add_argument('-t', dest='table', nargs='*', help='Table filter') |
|
16
cb7e13711a99
MyManager - create_conn() - allow same parameters as for PgManager.
Radek Brich <brich.radek@ifortuna.cz>
parents:
9
diff
changeset
|
12 |
self.parser.add_argument('--sql', action='store_true', help='Output is SQL script.') |
5 | 13 |
|
14 |
self.init() |
|
2 | 15 |
|
5 | 16 |
def main(self): |
17 |
srcbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('src')) |
|
18 |
dstbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('dst')) |
|
2 | 19 |
|
5 | 20 |
pgd = pgdiff.PgDiff(srcbrowser, dstbrowser) |
2 | 21 |
|
5 | 22 |
if self.args.schema: |
23 |
pgd.filter_schemas(include=self.args.schema) |
|
24 |
||
25 |
if self.args.table: |
|
26 |
pgd.filter_tables(include=self.args.table) |
|
2 | 27 |
|
16
cb7e13711a99
MyManager - create_conn() - allow same parameters as for PgManager.
Radek Brich <brich.radek@ifortuna.cz>
parents:
9
diff
changeset
|
28 |
if self.args.sql: |
cb7e13711a99
MyManager - create_conn() - allow same parameters as for PgManager.
Radek Brich <brich.radek@ifortuna.cz>
parents:
9
diff
changeset
|
29 |
pgd.print_patch() |
cb7e13711a99
MyManager - create_conn() - allow same parameters as for PgManager.
Radek Brich <brich.radek@ifortuna.cz>
parents:
9
diff
changeset
|
30 |
else: |
cb7e13711a99
MyManager - create_conn() - allow same parameters as for PgManager.
Radek Brich <brich.radek@ifortuna.cz>
parents:
9
diff
changeset
|
31 |
pgd.print_diff() |
5 | 32 |
|
2 | 33 |
|
5 | 34 |
tool = SchemaDiffTool() |
35 |
tool.main() |