From c94ccaf932b769a85ae43aa1ebaeff250e49cc58 Mon Sep 17 00:00:00 2001 From: Rick Morrison Date: Thu, 17 Apr 2008 19:07:12 +0000 Subject: [PATCH] Added 'odbc_options' keyword to the MSSQL dialect. Allows a partial ODBC connection string to be passed through to the connection string generator. --- CHANGES | 8 ++++++++ lib/sqlalchemy/databases/mssql.py | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index dc3d153c5f..8b6d86c062 100644 --- a/CHANGES +++ b/CHANGES @@ -51,6 +51,14 @@ CHANGES [ticket:1005] + - Added "odbc_options" parameter to engine / dburi + parameters. The given string is simply appended to the + SQLAlchemy-generated odbc connection string. + + This should obviate the need of adding a myriad of ODBC + options in the future. + + - firebird - Handle the "SUBSTRING(:string FROM :start FOR :length)" builtin. diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 6cc5f4fd34..55d4b7cf24 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -345,7 +345,6 @@ class MSSQLExecutionContext(default.DefaultExecutionContext): self.cursor.execute("SELECT @@identity AS lastrowid") row = self.cursor.fetchone() self._last_inserted_ids = [int(row[0])] + self._last_inserted_ids[1:] - # print "LAST ROW ID", self._last_inserted_ids super(MSSQLExecutionContext, self).post_exec() _ms_is_select = re.compile(r'\s*(?:SELECT|sp_columns|EXEC)', @@ -799,7 +798,12 @@ class MSSQLDialect_pyodbc(MSSQLDialect): # This should obviously be set to 'No' if you query a cp1253 encoded # database from a latin1 client... if 'odbc_autotranslate' in keys: - connectors.append("AutoTranslate=%s" % keys.pop("odbc_autotranslate")) + connectors.append("AutoTranslate=%s" % keys.pop("odbc_autotranslate")) + + # Allow specification of partial ODBC connect string + if 'odbc_options' in keys: + connectors.append(keys.pop('odbc_options')) + return [[";".join (connectors)], {}] def is_disconnect(self, e): -- 2.47.3