diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-12-19 23:02:45 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-12-19 23:02:45 +0000 |
commit | 9cccdfb0fdd54e4a254842e0f68cd41a33912776 (patch) | |
tree | 9e669d4f04f2d2bca531ce016f62ee2d88ec68ab | |
parent | 16ef52392c55341ae94edfca5e4feafe216844a4 (diff) | |
download | sqlalchemy-9cccdfb0fdd54e4a254842e0f68cd41a33912776.tar.gz |
removed the "create_execution_context()" method from dialects and replaced
with a more succinct "dialect.execution_ctx_cls" member
-rw-r--r-- | lib/sqlalchemy/databases/access.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/firebird.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/informix.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/maxdb.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 7 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/sqlite.py | 18 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/sybase.py | 16 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 12 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/default.py | 5 |
12 files changed, 22 insertions, 66 deletions
diff --git a/lib/sqlalchemy/databases/access.py b/lib/sqlalchemy/databases/access.py index b43aeb490..b5adc2015 100644 --- a/lib/sqlalchemy/databases/access.py +++ b/lib/sqlalchemy/databases/access.py @@ -209,9 +209,6 @@ class AccessDialect(default.DefaultDialect): connectors.append("PWD=%s" % opts.get("password", "")) return [[";".join(connectors)], {}] - def create_execution_context(self, *args, **kwargs): - return AccessExecutionContext(self, *args, **kwargs) - def last_inserted_ids(self): return self.context.last_inserted_ids @@ -425,3 +422,4 @@ dialect.schemagenerator = AccessSchemaGenerator dialect.schemadropper = AccessSchemaDropper dialect.preparer = AccessIdentifierPreparer dialect.defaultrunner = AccessDefaultRunner +dialect.execution_ctx_cls = AccessExecutionContext
\ No newline at end of file diff --git a/lib/sqlalchemy/databases/firebird.py b/lib/sqlalchemy/databases/firebird.py index 7c7d4793b..c42a2c7f5 100644 --- a/lib/sqlalchemy/databases/firebird.py +++ b/lib/sqlalchemy/databases/firebird.py @@ -302,9 +302,6 @@ class FBDialect(default.DefaultDialect): self.dbapi.init(type_conv=type_conv, concurrency_level=concurrency_level) return ([], opts) - def create_execution_context(self, *args, **kwargs): - return FBExecutionContext(self, *args, **kwargs) - def type_descriptor(self, typeobj): return sqltypes.adapt_type(typeobj, colspecs) @@ -768,3 +765,4 @@ dialect.schemagenerator = FBSchemaGenerator dialect.schemadropper = FBSchemaDropper dialect.defaultrunner = FBDefaultRunner dialect.preparer = FBIdentifierPreparer +dialect.execution_ctx_cls = FBExecutionContext
\ No newline at end of file diff --git a/lib/sqlalchemy/databases/informix.py b/lib/sqlalchemy/databases/informix.py index 27554d37e..2a9327cf5 100644 --- a/lib/sqlalchemy/databases/informix.py +++ b/lib/sqlalchemy/databases/informix.py @@ -239,9 +239,6 @@ class InfoDialect(default.DefaultDialect): return ([dsn], opt) - def create_execution_context(self , *args, **kwargs): - return InfoExecutionContext(self, *args, **kwargs) - def table_names(self, connection, schema): s = "select tabname from systables" return [row[0] for row in connection.execute(s)] @@ -493,3 +490,4 @@ dialect.statement_compiler = InfoCompiler dialect.schemagenerator = InfoSchemaGenerator dialect.schemadropper = InfoSchemaDropper dialect.preparer = InfoIdentifierPreparer +dialect.execution_ctx_cls = InfoExecutionContext
\ No newline at end of file diff --git a/lib/sqlalchemy/databases/maxdb.py b/lib/sqlalchemy/databases/maxdb.py index 0e7310ab6..dbe04f591 100644 --- a/lib/sqlalchemy/databases/maxdb.py +++ b/lib/sqlalchemy/databases/maxdb.py @@ -514,9 +514,6 @@ class MaxDBDialect(default.DefaultDialect): else: return sqltypes.adapt_type(typeobj, colspecs) - def create_execution_context(self, connection, **kw): - return MaxDBExecutionContext(self, connection, **kw) - def do_execute(self, cursor, statement, parameters, context=None): res = cursor.execute(statement, parameters) if isinstance(res, int) and context is not None: @@ -1099,3 +1096,4 @@ dialect.statement_compiler = MaxDBCompiler dialect.schemagenerator = MaxDBSchemaGenerator dialect.schemadropper = MaxDBSchemaDropper dialect.defaultrunner = MaxDBDefaultRunner +dialect.execution_ctx_cls = MaxDBExecutionContext
\ No newline at end of file diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 84f95fad9..bcfd975ab 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -377,6 +377,7 @@ class MSSQLDialect(default.DefaultDialect): name = 'mssql' supports_default_values = True supports_empty_insert = False + execution_ctx_cls = MSSQLExecutionContext colspecs = { sqltypes.Unicode : MSNVarchar, @@ -494,9 +495,6 @@ class MSSQLDialect(default.DefaultDialect): self.has_window_funcs = bool(int(opts.pop('has_window_funcs'))) return self.make_connect_string(opts) - def create_execution_context(self, *args, **kwargs): - return MSSQLExecutionContext(self, *args, **kwargs) - def type_descriptor(self, typeobj): newobj = sqltypes.adapt_type(typeobj, self.colspecs) # Some types need to know about the dialect @@ -774,6 +772,7 @@ class MSSQLDialect_pyodbc(MSSQLDialect): # PyODBC unicode is broken on UCS-4 builds supports_unicode = sys.maxunicode == 65535 supports_unicode_statements = supports_unicode + execution_ctx_cls = MSSQLExecutionContext_pyodbc def __init__(self, **params): super(MSSQLDialect_pyodbc, self).__init__(**params) @@ -850,8 +849,6 @@ class MSSQLDialect_pyodbc(MSSQLDialect): else: return False - def create_execution_context(self, *args, **kwargs): - return MSSQLExecutionContext_pyodbc(self, *args, **kwargs) def do_execute(self, cursor, statement, parameters, context=None, **kwargs): super(MSSQLDialect_pyodbc, self).do_execute(cursor, statement, parameters, context=context, **kwargs) diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 9c6c48e0f..1dc863233 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1496,9 +1496,6 @@ class MySQLDialect(default.DefaultDialect): opts['client_flag'] = client_flag return [[], opts] - def create_execution_context(self, connection, **kwargs): - return MySQLExecutionContext(self, connection, **kwargs) - def type_descriptor(self, typeobj): return sqltypes.adapt_type(typeobj, colspecs) @@ -2727,3 +2724,4 @@ dialect = MySQLDialect dialect.statement_compiler = MySQLCompiler dialect.schemagenerator = MySQLSchemaGenerator dialect.schemadropper = MySQLSchemaDropper +dialect.execution_ctx_cls = MySQLExecutionContext diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 72a0bb265..66e83ec2f 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -471,9 +471,6 @@ class OracleDialect(default.DefaultDialect): def do_recover_twophase(self, connection): pass - def create_execution_context(self, *args, **kwargs): - return OracleExecutionContext(self, *args, **kwargs) - def has_table(self, connection, table_name, schema=None): if not schema: schema = self.get_default_schema_name(connection) @@ -891,3 +888,4 @@ dialect.schemagenerator = OracleSchemaGenerator dialect.schemadropper = OracleSchemaDropper dialect.preparer = OracleIdentifierPreparer dialect.defaultrunner = OracleDefaultRunner +dialect.execution_ctx_cls = OracleExecutionContext
\ No newline at end of file diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 320c749bc..dd9fa5293 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -340,7 +340,7 @@ class PGDialect(default.DefaultDialect): default_paramstyle = 'pyformat' supports_default_values = True supports_empty_insert = False - + def __init__(self, server_side_cursors=False, **kwargs): default.DefaultDialect.__init__(self, **kwargs) self.server_side_cursors = server_side_cursors @@ -357,9 +357,6 @@ class PGDialect(default.DefaultDialect): opts.update(url.query) return ([], opts) - def create_execution_context(self, *args, **kwargs): - return PGExecutionContext(self, *args, **kwargs) - def type_descriptor(self, typeobj): return sqltypes.adapt_type(typeobj, colspecs) @@ -828,3 +825,4 @@ dialect.schemagenerator = PGSchemaGenerator dialect.schemadropper = PGSchemaDropper dialect.preparer = PGIdentifierPreparer dialect.defaultrunner = PGDefaultRunner +dialect.execution_ctx_cls = PGExecutionContext diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index 4226baf5a..6eabca1a9 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -407,9 +407,6 @@ class SQLiteDialect(default.DefaultDialect): def type_descriptor(self, typeobj): return sqltypes.adapt_type(typeobj, colspecs) - def create_execution_context(self, connection, **kwargs): - return SQLiteExecutionContext(self, connection, **kwargs) - def is_disconnect(self, e): return isinstance(e, self.dbapi.ProgrammingError) and "Cannot operate on a closed database." in str(e) @@ -590,19 +587,6 @@ class SQLiteSchemaGenerator(compiler.SchemaGenerator): colspec += " NOT NULL" return colspec - # this doesnt seem to be needed, although i suspect older versions of sqlite might still - # not directly support composite primary keys - #def visit_primary_key_constraint(self, constraint): - # if len(constraint) > 1: - # self.append(", \n") - # # put all PRIMARY KEYS in a UNIQUE index - # self.append("\tUNIQUE (%s)" % string.join([c.name for c in constraint],', ')) - # else: - # super(SQLiteSchemaGenerator, self).visit_primary_key_constraint(constraint) - -class SQLiteSchemaDropper(compiler.SchemaDropper): - pass - class SQLiteIdentifierPreparer(compiler.IdentifierPreparer): reserved_words = set([ 'add', 'after', 'all', 'alter', 'analyze', 'and', 'as', 'asc', @@ -631,5 +615,5 @@ dialect = SQLiteDialect dialect.poolclass = pool.SingletonThreadPool dialect.statement_compiler = SQLiteCompiler dialect.schemagenerator = SQLiteSchemaGenerator -dialect.schemadropper = SQLiteSchemaDropper dialect.preparer = SQLiteIdentifierPreparer +dialect.execution_ctx_cls = SQLiteExecutionContext
\ No newline at end of file diff --git a/lib/sqlalchemy/databases/sybase.py b/lib/sqlalchemy/databases/sybase.py index b464a3bcb..75b208056 100644 --- a/lib/sqlalchemy/databases/sybase.py +++ b/lib/sqlalchemy/databases/sybase.py @@ -455,7 +455,8 @@ class SybaseSQLDialect(default.DefaultDialect): supports_unicode_statements = False supports_sane_rowcount = False supports_sane_multi_rowcount = False - + execution_ctx_cls = SybaseSQLExecutionContext + def __new__(cls, dbapi=None, *args, **kwargs): if cls != SybaseSQLDialect: return super(SybaseSQLDialect, cls).__new__(cls, *args, **kwargs) @@ -489,9 +490,6 @@ class SybaseSQLDialect(default.DefaultDialect): raise ImportError('No DBAPI module detected for SybaseSQL - please install mxodbc') dbapi = classmethod(dbapi) - def create_execution_context(self, *args, **kwargs): - return SybaseSQLExecutionContext(self, *args, **kwargs) - def type_descriptor(self, typeobj): newobj = sqltypes.adapt_type(typeobj, self.colspecs) return newobj @@ -628,6 +626,8 @@ class SybaseSQLDialect(default.DefaultDialect): class SybaseSQLDialect_mxodbc(SybaseSQLDialect): + execution_ctx_cls = SybaseSQLExecutionContext_mxodbc + def __init__(self, **params): super(SybaseSQLDialect_mxodbc, self).__init__(**params) @@ -656,9 +656,6 @@ class SybaseSQLDialect_mxodbc(SybaseSQLDialect): #return True return False - def create_execution_context(self, *args, **kwargs): - return SybaseSQLExecutionContext_mxodbc(self, *args, **kwargs) - def do_execute(self, cursor, statement, parameters, context=None, **kwargs): super(SybaseSQLDialect_mxodbc, self).do_execute(cursor, statement, parameters, context=context, **kwargs) @@ -675,6 +672,8 @@ class SybaseSQLDialect_mxodbc(SybaseSQLDialect): class SybaseSQLDialect_pyodbc(SybaseSQLDialect): + execution_ctx_cls = SybaseSQLExecutionContext_pyodbc + def __init__(self, **params): super(SybaseSQLDialect_pyodbc, self).__init__(**params) self.dbapi_type_map = {'getdate' : SybaseDate_pyodbc()} @@ -701,9 +700,6 @@ class SybaseSQLDialect_pyodbc(SybaseSQLDialect): #return True return False - def create_execution_context(self, *args, **kwargs): - return SybaseSQLExecutionContext_pyodbc(self, *args, **kwargs) - def do_execute(self, cursor, statement, parameters, context=None, **kwargs): super(SybaseSQLDialect_pyodbc, self).do_execute(cursor, statement, parameters, context=context, **kwargs) diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index dbcd5b76b..9efd73a89 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -177,11 +177,6 @@ class Dialect(object): raise NotImplementedError() - def create_execution_context(self, connection, compiled=None, compiled_parameters=None, statement=None, parameters=None): - """Return a new :class:`~sqlalchemy.engine.ExecutionContext` object.""" - - raise NotImplementedError() - def do_begin(self, connection): """Provide an implementation of *connection.begin()*, given a DB-API connection.""" @@ -314,9 +309,7 @@ class ExecutionContext(object): a list of Column objects for which a server-side default or inline SQL expression value was fired off. applies to inserts and updates. - The Dialect should provide an ExecutionContext via the - create_execution_context() method. The `pre_exec` and `post_exec` - methods will be called for compiled statements. + """ def create_cursor(self): @@ -927,7 +920,8 @@ class Connection(Connectable): def __create_execution_context(self, **kwargs): try: - return self.engine.dialect.create_execution_context(connection=self, **kwargs) + dialect = self.engine.dialect + return dialect.execution_ctx_cls(dialect, connection=self, **kwargs) except Exception, e: self._handle_dbapi_exception(e, kwargs.get('statement', None), kwargs.get('parameters', None), None) raise diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 251cf8b2c..11fd43df5 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -59,9 +59,6 @@ class DefaultDialect(base.Dialect): raise exc.ArgumentError("Label length of %d is greater than this dialect's maximum identifier length of %d" % (label_length, self.max_identifier_length)) self.label_length = label_length - def create_execution_context(self, connection, **kwargs): - return DefaultExecutionContext(self, connection, **kwargs) - def type_descriptor(self, typeobj): """Provide a database-specific ``TypeEngine`` object, given the generic object which comes from the types module. @@ -367,3 +364,5 @@ class DefaultExecutionContext(base.ExecutionContext): self.postfetch_cols = self.compiled.postfetch self.prefetch_cols = self.compiled.prefetch + +DefaultDialect.execution_ctx_cls = DefaultExecutionContext
\ No newline at end of file |