[SQL-CVS] r2112 - home/phd/SQLObject/paramstyles/sqlobject/mssql
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2006-12-04 15:18:46
|
Author: phd Date: 2006-12-04 08:18:42 -0700 (Mon, 04 Dec 2006) New Revision: 2112 Modified: home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py Log: Merged patches from the revisions 2103:2111 from the trunk Modified: home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py =================================================================== --- home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py 2006-12-04 15:16:36 UTC (rev 2111) +++ home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py 2006-12-04 15:18:42 UTC (rev 2112) @@ -16,37 +16,42 @@ if not sqlmodule: try: import adodbapi as sqlmodule - self.dbconnection = sqlmodule.connect - # ADO uses unicode only (AFAIK) - self.usingUnicodeStrings = True + except ImportError: + import pymssql as sqlmodule - # Need to use SQLNCLI provider for SQL Server Express Edition - if kw.get("ncli"): - conn_str = "Provider=SQLNCLI;" - else: - conn_str = "Provider=SQLOLEDB;" + if sqlmodule.__name__ == 'adodbapi': + import adodbapi as sqlmodule + self.dbconnection = sqlmodule.connect + # ADO uses unicode only (AFAIK) + self.usingUnicodeStrings = True - conn_str += "Data Source=%s;Initial Catalog=%s;" + # Need to use SQLNCLI provider for SQL Server Express Edition + if kw.get("ncli"): + conn_str = "Provider=SQLNCLI;" + else: + conn_str = "Provider=SQLOLEDB;" - # MSDE does not allow SQL server login - if kw.get("sspi"): - conn_str += "Integrated Security=SSPI;Persist Security Info=False" - self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db)] - else: - conn_str += "User Id=%s;Password=%s" - self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db, keys.user, keys.password)] + conn_str += "Data Source=%s;Initial Catalog=%s;" - col.popKey(kw, "sspi") - col.popKey(kw, "ncli") + # MSDE does not allow SQL server login + if kw.get("sspi"): + conn_str += "Integrated Security=SSPI;Persist Security Info=False" + self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db)] + else: + conn_str += "User Id=%s;Password=%s" + self.make_conn_str = lambda keys: [conn_str % (keys.host, keys.db, keys.user, keys.password)] - except ImportError: # raise the exceptions other than ImportError for adodbapi absence - import pymssql as sqlmodule - self.dbconnection = sqlmodule.connect - sqlmodule.Binary = lambda st: str(st) - # don't know whether pymssql uses unicode - self.usingUnicodeStrings = False - self.make_conn_str = lambda keys: \ - ["", keys.user, keys.password, keys.host, keys.db] + col.popKey(kw, "sspi") + col.popKey(kw, "ncli") + + else: # pymssql + self.dbconnection = sqlmodule.connect + sqlmodule.Binary = lambda st: str(st) + # don't know whether pymssql uses unicode + self.usingUnicodeStrings = False + self.make_conn_str = lambda keys: \ + ["", keys.user, keys.password, keys.host, keys.db] + self.autoCommit=int(autoCommit) self.host = host self.db = db |