[python-win32] datetime values in adodbapi

Vernon D. Cole vernondcole at gmail.com
Mon Nov 6 10:07:49 EST 2017


[Sorry everyone. My kitten stepped on the keyboard and sent out a
one-letter reply.]

Yes, patches are accepted and welcome.  My last remaining Windows
development environment (I work mostly on Ubuntu these years) died several
months ago leaving me high and dry to do maintenance.  I have purchased its
replacement and promise to get back to work.  An assistant administrator
for adodbapi would be welcome, too.  I am 67 and will not last forever.
I also have a plan for a MSSQL Server test bed to be available for
volunteers to use for testing.

Bob:
  What SQL engine and version are you running?

--
Vernon Cole


On Mon, Nov 6, 2017 at 7:59 AM, Vernon D. Cole <vernondcole at gmail.com>
wrote:

> Y
>
> On Sat, Nov 4, 2017 at 6:27 AM, Bob Kline <bkline at rksystems.com> wrote:
>
>> The adodbapi package does not seem to handle datetime values
>> appropriately.
>>
>> import adodbapi
>> print(adodbapi.version)
>> cursor = adodbapi.connect(...)
>> cursor.execute("CREATE TABLE #t (i INT, d DATETIME)")
>> cursor.execute("INSERT INTO #t VALUES (42, GETDATE())")
>> cursor.execute("SELECT * FROM #t")
>> row = cursor.fetchone()
>> print("d={}".format(row.d))
>> cursor.execute("INSERT INTO #t VALUES (?, ?)", (43, row.d))
>> cursor.execute("SELECT * FROM #t WHERE i = 43")
>> row = cursor.fetchone()
>> print("d={}".format(row.d))
>>
>> When running under Python 2.7.13, the first print statement shows that
>> the datetime value has been correctly retrieved, preserving the
>> precision:
>>
>> d=2017-11-04 07:52:18.110000
>>
>> but then when the second INSERT is executed an exception is raised:
>>
>> pywintypes.com_error: (-2147352567 <(214)%20735-2567>, 'Exception
>> occurred.', (0,
>> u'ADODB.Parameter', u'Application uses a value of the wrong type for
>> the current operation.', u'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240652,
>> -2146824867 <(214)%20682-4867>), None)
>>
>> So the package isn't allowing the script to use the same value it was
>> given as a valid value for the d column by the package itself.
>>
>> When the script is run under Python 3.6.0, the exception is not
>> raised, but that's only because the datetime precision has been
>> discarded:
>>
>> d=2017-11-04 08:15:37
>> d=2017-11-04 08:15:37
>>
>> I get the same behavior with adodbapi 2.6.0.6 (which I downloaded from
>> the link which indicated (http://adodbapi.sourceforge.net/index.html)
>> that this is the latest version) and on 2.6.0.7, which is what pip
>> installed.
>>
>> I would like to help get both of these behaviors corrected (failure to
>> store datetime values with microsecond precision in Python 2.x, as
>> well as failure to preserve sub-second precision in retrieved values
>> in Python 3.x). Before I dig in to do the work, though, I want to
>> check in here to make sure patches are accepted so I don't spend time
>> on something that's not wanted.
>>
>> Thanks!
>>
>> --
>> Bob Kline
>> http://www.rksystems.com
>> mailto:bkline at rksystems.com
>> _______________________________________________
>> python-win32 mailing list
>> python-win32 at python.org
>> https://mail.python.org/mailman/listinfo/python-win32
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20171106/0cb84600/attachment-0001.html>


More information about the python-win32 mailing list