- Added stubs for small date type, [ticket:884]
+ - Added a new 'driver' keyword parameter for the pyodbc dialect.
+ Will substitute into the ODBC connection string if given,
+ defaults to 'SQL Server'.
+
- Improvements to pyodbc + Unix. If you couldn't get that
combination to work before, please try again.
super(MSDate, self).__init__(False)
def get_col_spec(self):
- return "SMALLDATETIME"
+ return "DATETIME"
+
+ def result_processor(self, dialect):
+ def process(value):
+ # If the DBAPI returns the value as datetime.datetime(), truncate it back to datetime.date()
+ if type(value) is datetime.datetime:
+ return value.date()
+ return value
+ return process
class MSTime(sqltypes.Time):
__zero_date = datetime.date(1900, 1, 1)
return value
return process
- def result_processor(self, dialect):
- def process(value):
- # pyodbc returns SMALLDATETIME values as datetime.datetime(). truncate it back to datetime.date()
- if type(value) is datetime.datetime:
- return value.date()
- return value
- return process
-
-class MSDate_pymssql(MSDate):
- def result_processor(self, dialect):
- def process(value):
- # pymssql will return SMALLDATETIME values as datetime.datetime(), truncate it back to datetime.date()
- if type(value) is datetime.datetime:
- return value.date()
- return value
- return process
-
class MSText(sqltypes.Text):
def get_col_spec(self):
if self.dialect.text_as_varchar:
'numeric' : MSNumeric,
'float' : MSFloat,
'datetime' : MSDateTime,
- 'smalldatetime' : MSDate,
+ 'date': MSDate,
+ 'smalldatetime' : MSSmallDate,
'binary' : MSBinary,
'varbinary' : MSBinary,
'bit': MSBoolean,
return module
import_dbapi = classmethod(import_dbapi)
- colspecs = MSSQLDialect.colspecs.copy()
- colspecs[sqltypes.Date] = MSDate_pymssql
-
ischema_names = MSSQLDialect.ischema_names.copy()
- ischema_names['smalldatetime'] = MSDate_pymssql
+
def __init__(self, **params):
super(MSSQLDialect_pymssql, self).__init__(**params)
self.use_scope_identity = hasattr(pyodbc.Cursor, 'nextset')
except:
pass
+ self.drivername = params.get('driver', 'SQL Server')
def import_dbapi(cls):
import pyodbc as module
if 'dsn' in keys:
connectors = ['dsn=%s' % keys['dsn']]
else:
- connectors = ["DRIVER={SQL Server}"]
+ connectors = ["DRIVER={%s}" % self.drivername]
if 'port' in keys:
connectors.append('Server=%s,%d' % (keys.get('host'), keys.get('port')))
else: