diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-30 22:15:19 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-03-30 22:15:19 +0000 |
commit | f11e9585b82de03d9ea42f7e19db7729f940dfe6 (patch) | |
tree | 356d282b9e927fa109ff3532337aef3c071cbb08 /lib/sqlalchemy/databases | |
parent | bd0bcc9f57e31bcc9a5f99e22daa6bfe93b24c72 (diff) | |
download | sqlalchemy-f11e9585b82de03d9ea42f7e19db7729f940dfe6.tar.gz |
some cache decorator calls...
Diffstat (limited to 'lib/sqlalchemy/databases')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 7 |
3 files changed, 9 insertions, 18 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index f8be94e2d..c820474c4 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1542,13 +1542,9 @@ class MySQLDialect(default.DefaultDialect): return False def get_default_schema_name(self, connection): - try: - return self._default_schema_name - except AttributeError: - name = self._default_schema_name = \ - connection.execute('SELECT DATABASE()').scalar() - return name - + return connection.execute('SELECT DATABASE()').scalar() + get_default_schema_name = util.cache_decorator(get_default_schema_name) + def table_names(self, connection, schema): """Return a Unicode SHOW TABLES from a given schema.""" diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 0c6e65f72..8a2df7f3b 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -379,13 +379,9 @@ class OracleDialect(default.DefaultDialect): return name.encode(self.encoding) def get_default_schema_name(self,connection): - try: - return self._default_schema_name - except AttributeError: - name = self._default_schema_name = \ - connection.execute('SELECT USER FROM DUAL').scalar() - return name - + return connection.execute('SELECT USER FROM DUAL').scalar() + get_default_schema_name = util.cache_decorator(get_default_schema_name) + def table_names(self, connection, schema): # note that table_names() isnt loading DBLINKed or synonym'ed tables if schema is None: diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index a34388a89..9dbf359b6 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -367,10 +367,9 @@ class PGDialect(default.DefaultDialect): return [row[0] for row in resultset] def get_default_schema_name(self, connection): - if not hasattr(self, '_default_schema_name'): - self._default_schema_name = connection.scalar("select current_schema()", None) - return self._default_schema_name - + return connection.scalar("select current_schema()", None) + get_default_schema_name = util.cache_decorator(get_default_schema_name) + def last_inserted_ids(self): if self.context.last_inserted_ids is None: raise exceptions.InvalidRequestError("no INSERT executed, or can't use cursor.lastrowid without Postgres OIDs enabled") |