From 5dfb97fcb5783f575f060749d76e8833eac1f55f Mon Sep 17 00:00:00 2001 From: gfawcett Date: Sun, 7 Feb 2010 23:12:20 +0000 Subject: [PATCH] deleted superfluous code from new pg backend. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/branches/eg-schema-experiment@769 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- .../backends/postgresql_with_schemas/base.py | 31 ---------------------- .../postgresql_with_schemas/introspection.py | 19 ------------- 2 files changed, 50 deletions(-) diff --git a/conifer/evergreen/backends/postgresql_with_schemas/base.py b/conifer/evergreen/backends/postgresql_with_schemas/base.py index 0a36cbc..e9ff1b8 100755 --- a/conifer/evergreen/backends/postgresql_with_schemas/base.py +++ b/conifer/evergreen/backends/postgresql_with_schemas/base.py @@ -21,34 +21,3 @@ class DatabaseWrapper(DatabaseWrapper): schemas = getattr(settings, 'DATABASE_PG_SCHEMAS', ['public']) cursor.execute('set search_path to %s;' % ','.join(schemas)) return cursor - - set_tz = False - settings_dict = self.settings_dict - if self.connection is None: - set_tz = True - if settings_dict['DATABASE_NAME'] == '': - from django.core.exceptions import ImproperlyConfigured - raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.") - conn_string = "dbname=%s" % settings_dict['DATABASE_NAME'] - if settings_dict['DATABASE_USER']: - conn_string = "user=%s %s" % (settings_dict['DATABASE_USER'], conn_string) - if settings_dict['DATABASE_PASSWORD']: - conn_string += " password='%s'" % settings_dict['DATABASE_PASSWORD'] - if settings_dict['DATABASE_HOST']: - conn_string += " host=%s" % settings_dict['DATABASE_HOST'] - if settings_dict['DATABASE_PORT']: - conn_string += " port=%s" % settings_dict['DATABASE_PORT'] - self.connection = Database.connect(conn_string, **settings_dict['DATABASE_OPTIONS']) - self.connection.set_isolation_level(1) # make transactions transparent to all cursors - connection_created.send(sender=self.__class__) - cursor = self.connection.cursor() - if set_tz: - cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']]) - if not hasattr(self, '_version'): - self.__class__._version = get_version(cursor) - if self._version[0:2] < (8, 0): - # No savepoint support for earlier version of PostgreSQL. - self.features.uses_savepoints = False - cursor.execute("SET client_encoding to 'UNICODE'") - cursor = UnicodeCursorWrapper(cursor, 'utf-8') - return cursor diff --git a/conifer/evergreen/backends/postgresql_with_schemas/introspection.py b/conifer/evergreen/backends/postgresql_with_schemas/introspection.py index 50d8306..2ed0fdc 100755 --- a/conifer/evergreen/backends/postgresql_with_schemas/introspection.py +++ b/conifer/evergreen/backends/postgresql_with_schemas/introspection.py @@ -5,25 +5,6 @@ SCHEMAS = getattr(settings, 'DATABASE_PG_SCHEMAS', ['public']) class DatabaseIntrospection(PostgresDatabaseIntrospection): - def get_relations(self, cursor, table_name): - """ - Returns a dictionary of {field_index: (field_index_other_table, other_table)} - representing all relationships to the given table. Indexes are 0-based. - """ - cursor.execute(""" - SELECT con.conkey, con.confkey, c2.relname - FROM pg_constraint con, pg_class c1, pg_class c2 - WHERE c1.oid = con.conrelid - AND c2.oid = con.confrelid - AND c1.relname = %s - AND con.contype = 'f'""", [table_name]) - relations = {} - for row in cursor.fetchall(): - # row[0] and row[1] are single-item lists, so grab the single item. - relations[row[0][0] - 1] = (row[1][0] - 1, row[2]) - return relations - - def get_table_list(self, cursor): "Returns a list of table names in the current database." schemas = ','.join("'%s'" % s for s in SCHEMAS) -- 2.11.0