385
|
1 import gerald
|
|
2
|
|
3 class SchemaSet(object):
|
|
4 def __init__(self, connection, rdbms, connect_string):
|
|
5 self.schemas = {}
|
|
6 curs = connection.cursor()
|
|
7 if rdbms == 'postgres':
|
|
8 curs.execute('SELECT schema_name FROM information_schema.schemata')
|
|
9 for row in curs.fetchall():
|
|
10 schema = row[0]
|
|
11 self.schemas[schema] = gerald.PostgresSchema(schema, connect_string)
|
|
12 elif rdbms == 'oracle':
|
|
13 curs.execute('SELECT DISTINCT owner FROM all_objects')
|
|
14 for row in curs.fetchall():
|
|
15 schema = row[0]
|
|
16
|
|
17
|
|
18
|
|
19 import psycopg2
|
|
20 connstr = 'postgres:/catherine:catherine@localhost/catherine'
|
|
21 conn = psycopg2.connect("dbname='catherine' user='catherine' password='catherine' host='localhost'")
|
|
22 ss = SchemaSet(conn, 'postgres', connstr)
|