diff --git a/adodbapi/adodbapi.py b/adodbapi/adodbapi.py index dc5cb03674..97d5bfb2a4 100644 --- a/adodbapi/adodbapi.py +++ b/adodbapi/adodbapi.py @@ -1,4 +1,4 @@ -"""adodbapi v2.1 - A python DB API 2.0 interface to Microsoft ADO +"""adodbapi v2.1.1 - A python DB API 2.0 interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund Email: @@ -245,9 +245,9 @@ def connect(connstr, timeout=30): #v2.1 Simons "Connection string as in the ADO documentation, SQL timeout in seconds" global verbose try: - conn=Dispatch('ADODB.Connection') if win32: - pythoncom.CoInitialize() #v2.1 Paj + pythoncom.CoInitialize() #v2.1 Paj + conn=Dispatch('ADODB.Connection') #connect _after_ CoIninialize v2.1.1 adamvan except: raise InterfaceError #Probably COM Error try: @@ -501,9 +501,10 @@ def _returnADOCommandParameters(self,adoCommand): retLst.append(pyObject) return retLst - def _makeDescriptionFromRS(self,rs): + def _makeDescriptionFromRS(self,rs): + self.rs = rs #v2.1.1 bkline if (rs == None) or (rs.State == adStateClosed): - self.rs=None + ##self.rs=None #removed v2.1.1 bkline self.description=None else: #self.rowcount=rs.RecordCount @@ -515,7 +516,7 @@ def _makeDescriptionFromRS(self,rs): # Switching to client-side cursors will force a static cursor, # and rowcount will then be set accurately [Cole] self.rowcount = -1 - self.rs=rs + ##self.rs=rs #removed v2.1.1 bkline nOfFields=rs.Fields.Count self.description=[] for i in range(nOfFields): @@ -541,7 +542,7 @@ def close(self): self.conn = None #this will make all future method calls on me throw an exception if self.rs and self.rs.State != adStateClosed: # rs exists and is open #v2.1 Rose self.rs.Close() #v2.1 Rose - self.rs = None #let go of the recordset os ADO will let it be disposed #v2.1 Rose + self.rs = None #let go of the recordset so ADO will let it be disposed #v2.1 Rose # ------------------------ # a note about Strategies: @@ -740,7 +741,7 @@ def _fetch(self, rows=None): if self.conn == None: self._raiseCursorError(Error,None) return - if rs == None: + if rs == None or rs.State == adStateClosed: #v2.1.1 bkline self._raiseCursorError(Error,None) return else: diff --git a/adodbapi/readme.txt b/adodbapi/readme.txt index 3b67ed20e5..0aa86c91dc 100644 --- a/adodbapi/readme.txt +++ b/adodbapi/readme.txt @@ -18,6 +18,11 @@ Prerequisites: * Python 2.3 or higher. * (this version included within) Mark Hammond's win32all python for windows extensions. + +Whats new in version 2.1.1? +1. Bugfix so nextset() will work even if a rowset is empty [ Bob Kline ] +2. Bugfix to call CoInitailize() before calling Dispatch() [ Adam Vandenberg ] + Whats new in version 2.1? 1. Use of Decimal.decimal data type for currency and numeric data. [ Cole ] 2. add optional timeout parameter to the connect method i.e.: @@ -63,7 +68,6 @@ License ------- LGPL, see http://www.opensource.org/licenses/lgpl-license.php - Documentation ------------- Start with: @@ -74,15 +78,12 @@ and look at the test cases in adodbapi/test directory. Mailing lists ------------- The adodbapi mailing lists have been deactivated. Submit comments to the -bug tracker. +pywin32 lists. -Contribute ----------- -Use the sourceforge bug tracking system to submit bugs, feature requests -and comments. Relase history -------------- +2.1.1 Bugfix to CoIninialize() and nextset() 2.1 Python 2.4 version 2.0 See what's new above. 1.0.1 Bug fix: Null values for numeric fields. Thanks to Tim Golden. diff --git a/adodbapi/tests/adodbapitest.py b/adodbapi/tests/adodbapitest.py index 1ad03137a3..87cf0a5de8 100644 --- a/adodbapi/tests/adodbapitest.py +++ b/adodbapi/tests/adodbapitest.py @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Updated for decimal data and version 2.1 by Vernon Cole + AS400 tests removed v 2.1.1 - Vernon Cole """ import unittest @@ -387,9 +388,10 @@ def testCurrencyDataType(self): crsr=conn.cursor() crsr.execute(tabdef) - for multiplier in (1,decimal.Decimal('2.5'),78,9999,999999,7007): + for multiplier in (1,decimal.Decimal('2.5'),78,9999,99999,7007): crsr.execute("DELETE FROM tblTemp") - crsr.execute("INSERT INTO tblTemp(fldCurr) VALUES (12.50*%f)" % multiplier) + correct = decimal.Decimal('12.50') * multiplier + crsr.execute("INSERT INTO tblTemp(fldCurr) VALUES (?)",[correct]) sql="SELECT fldCurr FROM tblTemp " try: @@ -398,7 +400,6 @@ def testCurrencyDataType(self): conn.printADOerrors() print sql fldcurr=crsr.fetchone()[0] - correct = decimal.Decimal('12.50') * multiplier self.assertEquals( fldcurr,correct) def testErrorConnect(self): @@ -534,6 +535,17 @@ def setUp(self): self.fail('SetUpError: Can not connect to the testdatabase, all other tests will fail...\nAdo error:%s' % adoConn.Errors(0)) self.engine = 'ACCESS' + def tearDown(self): + try: + self.conn.rollback() + except: + pass + try: + self.conn.close() + except: + pass + self.conn=None + def getConnection(self): return adodbapi.connect(adodbapitestconfig.connStrAccess) @@ -560,26 +572,6 @@ def testOkConnect(self): c=adodbapi.connect(adodbapitestconfig.connStrMySql) assert c != None -class TestADOwithAS400DB(CommonDBTests): - def setUp(self): - try: - adoConn=win32com.client.Dispatch("ADODB.Connection") - except: - self.fail('SetUpError: Is MDAC installed?') - try: - adoConn.Open(adodbapitestconfig.connStrAS400) - except: - self.fail('SetUpError: Can not connect to the testdatabase, all other tests will fail...\nAdo error:%s' % adoConn.Errors(0)) - self.engine = 'IBMDA400' - - def getConnection(self): - return adodbapi.connect(adodbapitestconfig.connStrAS400) - - def testOkConnect(self): - c=adodbapi.connect(adodbapitestconfig.connStrAS400) - assert c != None - - class TimeConverterInterfaceTest(unittest.TestCase): def testIDate(self): assert self.tc.Date(1990,2,2) @@ -731,8 +723,7 @@ def testTimestamp(self): suites.append( unittest.makeSuite(TestADOwithSQLServer,'test')) if adodbapitestconfig.doMySqlTest: suites.append( unittest.makeSuite(TestADOwithMySql,'test')) -if adodbapitestconfig.doAS400Test: - suites.append( unittest.makeSuite(TestADOwithAS400DB,'test')) + suite=unittest.TestSuite(suites) if __name__ == '__main__': defaultDateConverter=adodbapi.dateconverter diff --git a/adodbapi/tests/adodbapitestconfig.py b/adodbapi/tests/adodbapitestconfig.py index e23f38f570..776f36698d 100644 --- a/adodbapi/tests/adodbapitestconfig.py +++ b/adodbapi/tests/adodbapitestconfig.py @@ -4,13 +4,15 @@ doAccessTest = True doSqlServerTest = True +doMySqlTest = True + try: #If mx extensions are installed, use mxDateTime import mx.DateTime doMxDateTimeTest=True except: doMxDateTimeTest=False #Requires eGenixMXExtensions -doAS400Test = False -doMySqlTest = False + + import sys if float(sys.version[:3])>2.29: doDateTimeTest=True #Requires Python 2.3 Alpha2 @@ -81,10 +83,10 @@ doSqlServerTest = False if doMySqlTest: - _computername='5.128.134.143' + _computername='10.100.5.249' _databasename='test' - connStrMySql = 'Driver={MySQL ODBC 3.51 Driver};Server=%s;Port=3306;Database=%s;Option=3;' % \ + connStrMySql = 'Driver={MySQL ODBC 5.1 Driver};Server=%s;Port=3306;Database=%s;Option=3;' % \ (_computername,_databasename) print ' ...Testing MySql login...' try: @@ -94,20 +96,4 @@ print inst.args[0][2] # should be the error message doMySqlTest = False -if doAS400Test: - #OLE DB -> "PROVIDER=IBMDA400; DATA SOURCE=MY_SYSTEM_NAME;USER ID=myUserName;PASSWORD=myPwd;DEFAULT COLLECTION=MY_LIBRARY;" - connStrAS400skl = "Provider=IBMDA400; DATA SOURCE=%s;DEFAULT COLLECTION=%s;User ID=%s;Password=%s" - # NOTE! user's PC must have OLE support installed in IBM Client Access Express - _computername='PEPPER' - _databasename="DPDAN" - _username = raw_input(' AS400 User ID for data retrieval [%s]:' % defaultUser) - _password = getpass.getpass(' AS400 password:') #read the password - connStrAS400 = connStrAS400skl % (_computername,_databasename,_username,_password) #build the connection string - print ' ...Testing AS400 login...' - try: - s = adodbapi.connect(connStrAS400) #connect to server - s.close() - except adodbapi.DatabaseError, inst: - print inst.args[0][2] # should be the AS400 error message - doAS400Test = False - \ No newline at end of file + \ No newline at end of file