[pywin32-checkins] /hgroot/pywin32/pywin32: upgrade adodbapi to version 2.6
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2014-05-01 20:12:28
|
changeset ebe979332110 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=ebe979332110 summary: upgrade adodbapi to version 2.6 diffstat: CHANGES.txt | 7 +- adodbapi/__init__.py | 57 +- adodbapi/ado_consts.py | 15 +- adodbapi/adodbapi.py | 1358 +++++++++++-------------------- adodbapi/examples/db_print.py | 90 +- adodbapi/examples/db_table_names.py | 15 +- adodbapi/examples/test.mdb | 0 adodbapi/examples/xls_read.py | 9 +- adodbapi/examples/xls_write.py | 24 +- adodbapi/readme.txt | 226 +---- adodbapi/test/adodbapitest.py | 852 ++++++++++++++----- adodbapi/test/adodbapitestconfig.py | 159 ++- adodbapi/test/dbapi20.py | 173 ++- adodbapi/test/setuptestframework.py | 113 +- adodbapi/test/test_adodbapi_dbapi20.py | 98 +- adodbapi/test/tryconnection2.py | 50 +- adodbapi/test/tryconnection3.py | 50 +- setup.py | 5 +- 18 files changed, 1738 insertions(+), 1563 deletions(-) diffs (truncated from 4638 to 300 lines): diff -r d42964909493 -r ebe979332110 CHANGES.txt --- a/CHANGES.txt Tue Apr 01 15:17:20 2014 +1100 +++ b/CHANGES.txt Thu May 01 14:10:35 2014 -0600 @@ -22,11 +22,12 @@ Unfortunately, this means that only IExchangeManageStore::CreateStoreEntryID is currently available in a 64-bit build. (Nick Czeczulin) -* adodbapi updated to version 2.4.3 -- new examples folder includes short programs for - reading and writing .xls spreadsheets and reading ACCESS .mdb files using SQL. +* adodbapi updated to version 2.6 -- new examples folder includes short programs for + reading and writing .xls spreadsheets and reading ACCESS .mdb files using SQL. New functions .is64bit.Python() and .is64bit.os() to help pick the correct drivers. New function .schema_table.names() returns a list of all tables in a database. - see adodbapi/README.txt for more information. + Ability for a Windows computer to be a database proxy for a remote (Linux or Windows) unit. + see adodbapi/README.txt for more information. * Fix issue implementing COM objects from within a virtualenv (Kevin Smyth via issue #3597965) diff -r d42964909493 -r ebe979332110 adodbapi/__init__.py --- a/adodbapi/__init__.py Tue Apr 01 15:17:20 2014 +1100 +++ b/adodbapi/__init__.py Thu May 01 14:10:35 2014 -0600 @@ -1,3 +1,56 @@ -import ado_consts -from adodbapi import * +"""adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO +Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole +* http://sourceforge.net/projects/adodbapi +""" +import sys +import time + +if sys.version_info < (3,0): # in Python 2, define all symbols, just like the bad old way + from apibase import * + VariantConversionMap = MultiMap # old name. Should use apibase.MultiMap + from ado_consts import * + _makeByteBuffer = buffer +else: + # but if the user is running Python 3, then keep the dictionary clean + from .apibase import apilevel, threadsafety, paramstyle + from .apibase import Warning, Error, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError + from .apibase import InternalError, ProgrammingError, NotSupportedError, FetchFailedError + from .apibase import NUMBER, STRING, BINARY, DATETIME, ROWID + _makeByteBuffer = bytes + +from adodbapi import connect, Connection, __version__, dateconverter, Cursor + +def Binary(aString): + """This function constructs an object capable of holding a binary (long) string value. """ + return _makeByteBuffer(aString) + +def Date(year,month,day): + "This function constructs an object holding a date value. " + return dateconverter.Date(year,month,day) + +def Time(hour,minute,second): + "This function constructs an object holding a time value. " + return dateconverter.Time(hour,minute,second) + +def Timestamp(year,month,day,hour,minute,second): + "This function constructs an object holding a time stamp value. " + return dateconverter.Timestamp(year,month,day,hour,minute,second) + +def DateFromTicks(ticks): + """This function constructs an object holding a date value from the given ticks value + (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ + return Date(*time.gmtime(ticks)[:3]) + +def TimeFromTicks(ticks): + """This function constructs an object holding a time value from the given ticks value + (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ + return Time(*time.gmtime(ticks)[3:6]) + +def TimestampFromTicks(ticks): + """This function constructs an object holding a time stamp value from the given + ticks value (number of seconds since the epoch; + see the documentation of the standard Python time module for details). """ + return Timestamp(*time.gmtime(ticks)[:6]) + +version = 'adodbapi v' + __version__ diff -r d42964909493 -r ebe979332110 adodbapi/ado_consts.py --- a/adodbapi/ado_consts.py Tue Apr 01 15:17:20 2014 +1100 +++ b/adodbapi/ado_consts.py Thu May 01 14:10:35 2014 -0600 @@ -170,8 +170,10 @@ #adInteger 3 Indicates a four-byte signed integer (DBTYPE_I4). #adSingle 4 Indicates a single-precision floating-point value (DBTYPE_R4). #adDouble 5 Indicates a double-precision floating-point value (DBTYPE_R8). -#adCurrency 6 Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000. -#adDate 7 Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day. +#adCurrency 6 Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number +# with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000. +#adDate 7 Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is +# the number of days since December 30, 1899, and the fractional part of which is the fraction of a day. #adBSTR 8 Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR). #adIDispatch 9 Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH). #adError 10 Indicates a 32-bit error code (DBTYPE_ERROR). @@ -185,12 +187,14 @@ #adUnsignedInt 19 Indicates a four-byte unsigned integer (DBTYPE_UI4). #adBigInt 20 Indicates an eight-byte signed integer (DBTYPE_I8). #adUnsignedBigInt 21 Indicates an eight-byte unsigned integer (DBTYPE_UI8). -#adFileTime 64 Indicates a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (DBTYPE_FILETIME). +#adFileTime 64 Indicates a 64-bit value representing the number of 100-nanosecond intervals since +# January 1, 1601 (DBTYPE_FILETIME). #adGUID 72 Indicates a globally unique identifier (GUID) (DBTYPE_GUID). #adBinary 128 Indicates a binary value (DBTYPE_BYTES). #adChar 129 Indicates a string value (DBTYPE_STR). #adWChar 130 Indicates a null-terminated Unicode character string (DBTYPE_WSTR). -#adNumeric 131 Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC). adUserDefined 132 Indicates a user-defined variable (DBTYPE_UDT). +#adNumeric 131 Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC). +# adUserDefined 132 Indicates a user-defined variable (DBTYPE_UDT). #adUserDefined 132 Indicates a user-defined variable (DBTYPE_UDT). #adDBDate 133 Indicates a date value (yyyymmdd) (DBTYPE_DBDATE). #adDBTime 134 Indicates a time value (hhmmss) (DBTYPE_DBTIME). @@ -204,7 +208,8 @@ #adLongVarWChar 203 Indicates a long null-terminated Unicode string value (Parameter object only). #adVarBinary 204 Indicates a binary value (Parameter object only). #adLongVarBinary 205 Indicates a long binary value (Parameter object only). -#adArray (Does not apply to ADOX.) 0x2000 A flag value, always combined with another data type constant, that indicates an array of that other data type. +#adArray (Does not apply to ADOX.) 0x2000 A flag value, always combined with another data type constant, +# that indicates an array of that other data type. # Error codes to names adoErrors= { diff -r d42964909493 -r ebe979332110 adodbapi/adodbapi.py --- a/adodbapi/adodbapi.py Tue Apr 01 15:17:20 2014 +1100 +++ b/adodbapi/adodbapi.py Thu May 01 14:10:35 2014 -0600 @@ -1,6 +1,6 @@ """adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO -Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole +Copyright (C) 2002 Henrik Ekelund, versions 2.1 and later by Vernon Cole * http://sourceforge.net/projects/pywin32 * http://sourceforge.net/projects/adodbapi @@ -22,31 +22,32 @@ DB-API 2.0 specification: http://www.python.org/dev/peps/pep-0249/ -This module source should run correctly in CPython versions 2.3 and later, +This module source should run correctly in CPython versions 2.5 and later, or IronPython version 2.6 and later, or, after running through 2to3.py, CPython 3.0 or later. """ -__version__ = '2.4.3' +__version__ = '2.6.0.6' version = 'adodbapi v' + __version__ -# N.O.T.E.:... -# if you have been using an older version of adodbapi and are getting errors because -# numeric and monitary data columns are now returned as Decimal data, -# try adding the following line to get that data as strings: ... -#adodbapi.variantConversions[adodbapi.adoCurrencyTypes]=adodbapi.cvtString # get currency as strings -#adodbapi.variantConversions[adodbapi.adoExactNumericTypes]=adodbapi.cvtString import sys -import time -#import traceback -import datetime +import copy +import decimal +import os -import decimal -# or # from django.utils import _decimal as decimal +import process_connect_string +import ado_consts as adc +import apibase as api +try: + verbose = int(os.environ['ADODBAPI_VERBOSE']) +except: + verbose = False +if verbose: + print(version) -onIronPython = sys.platform == 'cli' # --- define objects to smooth out IronPython <-> CPython differences -if onIronPython: +onWin32 = False # assume the worst +if api.onIronPython: from System import Activator, Type, DBNull, DateTime, Array, Byte from System import Decimal as SystemDecimal from clr import Reference @@ -55,277 +56,65 @@ return Activator.CreateInstance(type) def getIndexedValue(obj,index): return obj.Item[index] -else: #pywin32 +else: # try pywin32 try: import win32com.client import pythoncom import pywintypes - pythoncom.__future_currency__ = True + onWin32 = True def Dispatch(dispatch): return win32com.client.Dispatch(dispatch) except ImportError: import warnings - warnings.warn("pywin32 package required but not found.",ImportWarning) + warnings.warn("pywin32 package (or IronPython) required for adodbapi.",ImportWarning) def getIndexedValue(obj,index): return obj(index) - DBNull = type(None) - DateTime = type(NotImplemented) #impossible value -import ado_consts as adc #internal to this module, use the new sub_module +try: + from collections import Mapping +except ImportError: # Python 2.5 + Mapping = dict # this will handle the most common case # --- define objects to smooth out Python3000 <-> Python 2.x differences unicodeType = unicode #this line will be altered by 2to3.py to '= str' longType = long #this line will be altered by 2to3.py to '= int' -if sys.version[0] >= '3': #python 3.x +if sys.version_info >= (3,0): #python 3.x StringTypes = str - makeByteBuffer = bytes - memoryViewType = memoryview - _BaseException = Exception + maxint = sys.maxsize else: #python 2.x - from exceptions import StandardError as _BaseException - memoryViewType = type(buffer('')) - makeByteBuffer = buffer - try: #jdhardy -- handle bytes under IronPython - bytes - except NameError: - bytes = str StringTypes = (str,unicode) # will be messed up by 2to3 but never used - from ado_consts import * #define old way of getting constants (for callers) - -def standardErrorHandler(connection,cursor,errorclass,errorvalue): - err = (errorclass,errorvalue) - connection.messages.append(err) - if cursor is not None: - cursor.messages.append(err) - raise errorclass(errorvalue) - -# ----- Time converters ---------------------------------------------- - -# all purpose date to ISO format converter -def _dateObjectToIsoFormatString(obj): - if isinstance(obj, datetime.datetime): - s = obj.strftime('%Y-%m-%d %H:%M:%S') - elif isinstance(obj, datetime.date): #exact midnight - s = obj.strftime('%Y-%m-%d 00:00:00') - elif isinstance(obj, time.struct_time): - s = time.strftime('%Y-%m-%d %H:%M:%S',obj) - else: - try: #usually datetime.datetime - s = obj.isoformat() - except: #but may be mxdatetime - s = obj.Format('%Y-%m-%d %H:%M:%S') - return s - -class TimeConverter(object): # this is a generic time converter skeleton - def __init__(self): # the details will be filled in by instances - self._ordinal_1899_12_31=datetime.date(1899,12,31).toordinal()-1 - #Use self.types to compare if an input parameter is a datetime - self.types = (type(self.Date(2000,1,1)), - type(self.Time(12,1,1)), - type(self.Timestamp(2000,1,1,12,1,1))) - def COMDate(self,obj): - 'Returns a ComDate from a datetime in inputformat' - raise NotImplementedError #"Abstract class" - def DateObjectFromCOMDate(self,comDate): - 'Returns an object of the wanted type from a ComDate' - raise NotImplementedError #"Abstract class" - def Date(self,year,month,day): - "This function constructs an object holding a date value. " - raise NotImplementedError #"Abstract class" - def Time(self,hour,minute,second): - "This function constructs an object holding a time value. " - raise NotImplementedError #"Abstract class" - def Timestamp(self,year,month,day,hour,minute,second): - "This function constructs an object holding a time stamp value. " - raise NotImplementedError #"Abstract class" - def DateObjectToIsoFormatString(self,obj): - "This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional) " - raise NotImplementedError #"Abstract class" - -# -- Optional: if mx extensions are installed you may use mxDateTime ---- -try: - import mx.DateTime - mxDateTime = True -# to change the default time converter, use something like: -# adodbapi.adodbapi.dateconverter = adodbapi.mxDateTimeConverter() -except: - mxDateTime = False -if mxDateTime: - class mxDateTimeConverter(TimeConverter): # used optionally if - def COMDate(self,obj): - return obj.COMDate() - def DateObjectFromCOMDate(self,comDate): - return mx.DateTime.DateTimeFromCOMDate(comDate) - def DateObjectFromCOMDate(self,comDate): - return mx.DateTime.DateTimeFromCOMDate(comDate) - def Date(self,year,month,day): |