[pywin32-checkins] pywin32/adodbapi adodbapi.py, 1.6, 1.7 readme.txt, 1.6, 1.7
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
|
From: Vernon C. <kf...@us...> - 2009-02-02 03:48:48
|
Update of /cvsroot/pywin32/pywin32/adodbapi In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29916 Modified Files: adodbapi.py readme.txt Log Message: adodbapi v2.2.6 works with Python 3.0 (after 2to3) Index: adodbapi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/adodbapi/adodbapi.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** adodbapi.py 8 Dec 2008 18:13:53 -0000 1.6 --- adodbapi.py 2 Feb 2009 03:48:41 -0000 1.7 *************** *** 1,3 **** ! """adodbapi v2.2.4 - A python DB API 2.0 interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund --- 1,3 ---- ! """adodbapi v2.2.6 - A python DB API 2.0 interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund *************** *** 29,33 **** import string - import exceptions import time import calendar --- 29,32 ---- *************** *** 38,41 **** --- 37,46 ---- try: + from exceptions import StandardError as _BaseException + except ImportError: + # py3k + _BaseException = Exception + + try: import decimal except ImportError: #perhaps running Cpython 2.3 *************** *** 60,63 **** --- 65,69 ---- else: #pywin32 import pythoncom + import pywintypes pythoncom.__future_currency__ = True def Dispatch(dispatch): *************** *** 66,70 **** return obj(index) DBNull = type(None) ! DateTime = type(NotImplemented) #impossible value # --- define objects to smooth out Python3000 <-> Python 2.x differences --- 72,76 ---- return obj(index) DBNull = type(None) ! DateTime = type(NotImplemented) #impossible value # --- define objects to smooth out Python3000 <-> Python 2.x differences *************** *** 74,79 **** if sys.version[0] == '3': StringTypes = [str] else: ! memoryview = buffer bytes = str StringTypes = types.StringTypes # will be messed up by 2to3 but never used --- 80,86 ---- if sys.version[0] == '3': StringTypes = [str] + makeByteBuffer = bytes else: ! makeByteBuffer = buffer bytes = str StringTypes = types.StringTypes # will be messed up by 2to3 but never used *************** *** 152,156 **** def DateObjectFromCOMDate(self,comDate): #ComDate is number of days since 1899-12-31 ! if isinstance(comDate,DateTime): fComDate = comDate.ToOADate() else: --- 159,165 ---- def DateObjectFromCOMDate(self,comDate): #ComDate is number of days since 1899-12-31 ! if isinstance(comDate,datetime.datetime): ! return comDate.replace(tzinfo=None) # make non aware ! elif isinstance(comDate,DateTime): fComDate = comDate.ToOADate() else: *************** *** 187,190 **** --- 196,201 ---- 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') else: try: #usually datetime.datetime *************** *** 197,204 **** def __init__(self): TimeConverter.__init__(self) ! if onIronPython: ! def COMDate(self,timeobj): ! return self.COMDateFromTuple(timeobj) ! def COMDateFromTuple(self,t): d = datetime.date(t[0],t[1],t[2]) integerPart = d.toordinal() - self._ordinal_1899_12_31 --- 208,214 ---- def __init__(self): TimeConverter.__init__(self) ! def COMDate(self,timeobj): ! return self.COMDateFromTuple(timeobj) ! def COMDateFromTuple(self,t): d = datetime.date(t[0],t[1],t[2]) integerPart = d.toordinal() - self._ordinal_1899_12_31 *************** *** 206,219 **** fractPart = sec / 86400.0 return integerPart + fractPart ! else: #pywin32 ! def COMDate(self,timeobj): ! return float(pythoncom.MakeTime(time.mktime(timeobj))) ! def COMDateFromTuple(self,YMDHMSmsTuple): ! t=pythoncom.MakeTime(YMDHMSmsTuple) ! return float(t) ! def DateObjectFromCOMDate(self,comDate): 'Returns ticks since 1970' ! if isinstance(comDate,DateTime): fcomDate = comDate.ToOADate() else: --- 216,225 ---- fractPart = sec / 86400.0 return integerPart + fractPart ! def DateObjectFromCOMDate(self,comDate): 'Returns ticks since 1970' ! if isinstance(comDate,datetime.datetime): ! return comDate.timetuple() ! elif isinstance(comDate,DateTime): fcomDate = comDate.ToOADate() else: *************** *** 240,244 **** return s ! class Error(exceptions.StandardError): pass #Exception that is the base class of all other error #exceptions. You can use this to catch all errors with one --- 246,250 ---- return s ! class Error(_BaseException): pass #Exception that is the base class of all other error #exceptions. You can use this to catch all errors with one *************** *** 248,252 **** #module exceptions). ! class Warning(exceptions.StandardError): pass --- 254,258 ---- #module exceptions). ! class Warning(_BaseException): pass *************** *** 342,348 **** class Connection(object): ! from adodbapi import Warning, Error, InterfaceError, DataError, \ ! DatabaseError, OperationalError, IntegrityError, InternalError, \ ! NotSupportedError, ProgrammingError #required by api definition def __init__(self,adoConn): self.adoConn=adoConn --- 348,363 ---- class Connection(object): ! # include connection attributes required by api definition. ! Warning = Warning ! Error = Error ! InterfaceError = InterfaceError ! DataError = DataError ! DatabaseError = DatabaseError ! OperationalError = OperationalError ! IntegrityError = IntegrityError ! InternalError = InternalError ! NotSupportedError = NotSupportedError ! ProgrammingError = ProgrammingError ! def __init__(self,adoConn): self.adoConn=adoConn *************** *** 487,491 **** ## The attribute is -1 in case no executeXXX() has been performed on the cursor or ## the rowcount of the last operation is not determinable by the interface.[7] - ## N.O.T.E. -- adodbapi returns "-1" by default for all select statements arraysize=1 --- 502,505 ---- *************** *** 544,550 **** def _makeDescriptionFromRS(self,rs): self.rs = rs #v2.1.1 bkline ! if (rs == None) or (rs.State == adStateClosed): ! ##self.rs=None #removed v2.1.1 bkline ! self.description=None else: # Since the current implementation has a forward-only cursor, RecordCount will always return -1 --- 558,565 ---- def _makeDescriptionFromRS(self,rs): self.rs = rs #v2.1.1 bkline ! if not rs: ! self.description = None ! elif rs.State == adStateClosed: ! self.description = None else: # Since the current implementation has a forward-only cursor, RecordCount will always return -1 *************** *** 701,707 **** ra = Reference[int]() rs = self.cmd.Execute(ra) ! adoRetVal=(rs,ra.Value) #return a tuple like win32 does else: #pywin32 ! adoRetVal=self.cmd.Execute() # ----- ------------------------------- --- except Exception, e: --- 716,722 ---- ra = Reference[int]() rs = self.cmd.Execute(ra) ! count = ra.Value else: #pywin32 ! rs, count = self.cmd.Execute() # ----- ------------------------------- --- except Exception, e: *************** *** 717,725 **** return - rs=adoRetVal[0] try: self.rowcount = rs.RecordCount except: ! self.rowcount = adoRetVal[1] self._makeDescriptionFromRS(rs) --- 732,739 ---- return try: self.rowcount = rs.RecordCount except: ! self.rowcount = count self._makeDescriptionFromRS(rs) *************** *** 788,792 **** self._raiseCursorError(Error,None) return ! if rs == None or rs.State == adStateClosed: #v2.1.1 bkline self._raiseCursorError(Error,None) return --- 802,806 ---- self._raiseCursorError(Error,None) return ! if not rs or rs.State == adStateClosed: #v2.1.1 bkline self._raiseCursorError(Error,None) return *************** *** 878,885 **** """ self.messages=[] ! if self.conn == None: self._raiseCursorError(Error,None) return ! if self.rs == None: self._raiseCursorError(Error,None) return --- 892,899 ---- """ self.messages=[] ! if not self.conn: self._raiseCursorError(Error,None) return ! if not self.rs: self._raiseCursorError(Error,None) return *************** *** 956,960 **** def Binary(aString): """This function constructs an object capable of holding a binary (long) string value. """ ! return memoryview(aString) #v2.1 Cole comment out: BinaryType = Binary('a') --- 970,974 ---- def Binary(aString): """This function constructs an object capable of holding a binary (long) string value. """ ! return makeByteBuffer(aString) #v2.1 Cole comment out: BinaryType = Binary('a') *************** *** 1145,1152 **** self.values = valuesTuple ! def __cmp__(self,other): ! if other in self.values: ! return 0 ! return 1 adoIntegerTypes=(adInteger,adSmallInt,adTinyInt,adUnsignedInt, --- 1159,1164 ---- self.values = valuesTuple ! def __eq__(self,other): ! return other in self.values adoIntegerTypes=(adInteger,adSmallInt,adTinyInt,adUnsignedInt, *************** *** 1192,1196 **** typeMap[bytes] = adBSTR, # 2.x string type else: #python 3.0 integrated integers ! ## Should this differentiote between an int that fits ion an long and one that requires 64 bit datatype? typeMap[int] = adBigInt --- 1204,1208 ---- typeMap[bytes] = adBSTR, # 2.x string type else: #python 3.0 integrated integers ! ## Should this differentiote between an int that fits in a long and one that requires 64 bit datatype? typeMap[int] = adBigInt *************** *** 1247,1251 **** def cvtBuffer(variant): ! return memoryview(variant) def cvtUnicode(variant): --- 1259,1263 ---- def cvtBuffer(variant): ! return makeByteBuffer(variant) def cvtUnicode(variant): Index: readme.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/adodbapi/readme.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** readme.txt 8 Dec 2008 18:13:53 -0000 1.6 --- readme.txt 2 Feb 2009 03:48:41 -0000 1.7 *************** *** 31,38 **** adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtFloat or: ! adodbapi.variantConversions[adodbapi.adNumeric] = my_convertion_function ............ Whats new in version 2.2.4 1. Ready for Python3? -- refactored so that 2to3 will inject very few errors, seems to be almost runnable in Pyk3. What happened to version 2.2.3? --- 31,51 ---- adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtFloat or: ! adodbapi.variantConversions[adodbapi.adNumeric] = write_your_own_convertion_function ............ + Whats new in version 2.2.6 + 1. Actually works in Python 3.0 (using pywin32 212.6) after running thru 2to3 + 2. (Produces an error in dbapi20 test when trying adodbapi.Buffer('This is a string') in Python 3.0) + 3. When a value with an exact midnight time is retrieved from a DATETIME column, return a datetime.datetime, + not a datetime.date. + + Whats new in version 2.2.5 + 1. Exception definition cleanups for for Python 3.0 readiness [Mark Hammond] + 2. Remove depreciated pythoncom.MakeTime calls (now uses pywintypes.Time) + 3. Change tests to default to local SQL server. + 4. Add an access-type database file for demo use. + Whats new in version 2.2.4 1. Ready for Python3? -- refactored so that 2to3 will inject very few errors, seems to be almost runnable in Pyk3. + 2. Use new function getIndexedValue() to hide differences between IronPython and pywin32. What happened to version 2.2.3? *************** *** 122,126 **** Relase history -------------- ! 2.2.2 Iron Python support complete. 2.2.1 Bugfix for string truncation 2.2 Code cleanup. added feature: "adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtString" --- 135,141 ---- Relase history -------------- ! 2.2.4 Ready for 2to3 convertion. Refactor to be more readable. Added function getIndexedValue() for IPy 2.0. ! 2.2.3 (withdrawn) ! 2.2.2 Iron Python support complete. 2.2.1 Bugfix for string truncation 2.2 Code cleanup. added feature: "adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtString" |