summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/connectors/pyodbc.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-03-19 21:37:42 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-03-19 21:37:42 -0400
commit1398268c42667d5feb148cf5f6e27aeaecfe35e9 (patch)
tree8401af0c07dada3a76a897581703fc4babaebaa4 /lib/sqlalchemy/connectors/pyodbc.py
parent60c9d3daae7586bd12c4ec77a10f3bc0275ca1de (diff)
downloadsqlalchemy-1398268c42667d5feb148cf5f6e27aeaecfe35e9.tar.gz
re-split PyODBCNumeric among Sybase and MS-SQL, they can't be shared.
MS-SQL really needs the pure string approach else crashes occur on windows.
Diffstat (limited to 'lib/sqlalchemy/connectors/pyodbc.py')
-rw-r--r--lib/sqlalchemy/connectors/pyodbc.py43
1 files changed, 0 insertions, 43 deletions
diff --git a/lib/sqlalchemy/connectors/pyodbc.py b/lib/sqlalchemy/connectors/pyodbc.py
index 5cf00bc92..b291f3e16 100644
--- a/lib/sqlalchemy/connectors/pyodbc.py
+++ b/lib/sqlalchemy/connectors/pyodbc.py
@@ -5,49 +5,6 @@ import sys
import re
import urllib
import decimal
-from sqlalchemy import processors, types as sqltypes
-
-class PyODBCNumeric(sqltypes.Numeric):
- """Turns Decimals with adjusted() < -6 into floats, > 7 into strings"""
-
- convert_large_decimals_to_string = False
-
- def bind_processor(self, dialect):
- super_process = super(PyODBCNumeric, self).bind_processor(dialect)
-
- def process(value):
- if self.asdecimal and \
- isinstance(value, decimal.Decimal):
-
- if value.adjusted() < -6:
- return processors.to_float(value)
- elif self.convert_large_decimals_to_string and \
- value.adjusted() > 7:
- return self._large_dec_to_string(value)
-
- if super_process:
- return super_process(value)
- else:
- return value
- return process
-
- def _large_dec_to_string(self, value):
- if 'E' in str(value):
- result = "%s%s%s" % (
- (value < 0 and '-' or ''),
- "".join([str(s) for s in value._int]),
- "0" * (value.adjusted() - (len(value._int)-1)))
- else:
- if (len(value._int) - 1) > value.adjusted():
- result = "%s%s.%s" % (
- (value < 0 and '-' or ''),
- "".join([str(s) for s in value._int][0:value.adjusted() + 1]),
- "".join([str(s) for s in value._int][value.adjusted() + 1:]))
- else:
- result = "%s%s" % (
- (value < 0 and '-' or ''),
- "".join([str(s) for s in value._int][0:value.adjusted() + 1]))
- return result
class PyODBCConnector(Connector):
driver='pyodbc'