Mercurial > sqlpython
diff sqlpython/sqlpy_gerald.py @ 385:0f019dfb795f
new file for gerald objects
author | catherine@DellZilla |
---|---|
date | Thu, 13 Aug 2009 14:33:55 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sqlpython/sqlpy_gerald.py Thu Aug 13 14:33:55 2009 -0400 @@ -0,0 +1,22 @@ +import gerald + +class SchemaSet(object): + def __init__(self, connection, rdbms, connect_string): + self.schemas = {} + curs = connection.cursor() + if rdbms == 'postgres': + curs.execute('SELECT schema_name FROM information_schema.schemata') + for row in curs.fetchall(): + schema = row[0] + self.schemas[schema] = gerald.PostgresSchema(schema, connect_string) + elif rdbms == 'oracle': + curs.execute('SELECT DISTINCT owner FROM all_objects') + for row in curs.fetchall(): + schema = row[0] + + + +import psycopg2 +connstr = 'postgres:/catherine:catherine@localhost/catherine' +conn = psycopg2.connect("dbname='catherine' user='catherine' password='catherine' host='localhost'") +ss = SchemaSet(conn, 'postgres', connstr)