Discussion:
[python-win32] Adodbapi date param error with MS access
Adrián Panella
2015-05-05 01:13:23 UTC
Permalink
Hi, I'am trying to use adodbapi to wrap a connection to an .accdb MS Access database and I'm getting an error when executing a query with a date parameter.For what I could deduce the problem is that it converts to COMDate only if "settings_known" is set, which seems not to be the case for Access querys, and defaults to assuming that the parameter is a string even if it is a datetime object.
I have solved the problem changing the following lines of code in adodbapi.py (in function _configure_parameter):
195 elif type(value) in dateconverter.types: 196 (old) #if settings_known and adotype in api.adoDateTimeTypes: 196 (new) if adotype in api.adoDateTimeTypes: 197 p.Value = dateconverter.COMDate(value) 198 else: #probably a string
This works but it is not very portable as it requires to change library code on each installation.
Any suggestions?
I have also tried running it as a stored procedure (with callproc), but in that case it tries to retrieve paramenter information (cmd.Parameters.Refresh). Which it does without error but getting all blanks. So it doesnŽt work either.
Thanks
Vernon D. Cole
2015-05-05 22:25:15 UTC
Permalink
Thanks for bringing this to attention. That exception was in the code (in
a slightly different form) when I inherited it many years ago. There was
once a note to the effect that it was needed to work around a bug in
Access. It is very likely that the Jet database engine has been improved in
the last decade and the workaround is no longer necessary. Perhaps we can
get rid of it.

What version of the Jet provider are you using?

Do you feel confident that your testing to determine that "this works" was
extensive enough to release the patch generally?
--
Vernon Cole
(adodbapi maintainer)
Post by Adrián Panella
Hi, I'am trying to use adodbapi to wrap a connection to an .accdb MS
Access database and I'm getting an error when executing a query with a date
parameter.
For what I could deduce the problem is that it converts to COMDate only if
"settings_known" is set, which seems not to be the case for Access querys,
and defaults to assuming that the parameter is a string even if it is a
datetime object.
I have solved the problem changing the following lines of code in
197 p.Value = dateconverter.COMDate(value)
198 else: #probably a string
This works but it is not very portable as it requires to change library
code on each installation.
Any suggestions?
I have also tried running it as a stored procedure (with callproc), but in
that case it tries to retrieve paramenter information
(cmd.Parameters.Refresh). Which it does without error but getting all
blanks. So it doesnÂŽt work either.
Thanks
_______________________________________________
python-win32 mailing list
https://mail.python.org/mailman/listinfo/python-win32
Adrián Panella
2015-05-09 17:02:08 UTC
Permalink
Hi.
I'm using the last ACE driver.

I haven't done enough testing to release it. I was first checking here. But I will do it.

I think it's not completely general as it doesn't solve the problem with callproc.

I'll do some more testing also with the last JET driver and come back, but I can't check side effects with other providers.

Adrian
Thanks for bringing this to attention. That exception was in the code (in a slightly different form) when I inherited it many years ago. There was once a note to the effect that it was needed to work around a bug in Access. It is very likely that the Jet database engine has been improved in the last decade and the workaround is no longer necessary. Perhaps we can get rid of it.
What version of the Jet provider are you using?
Do you feel confident that your testing to determine that "this works" was extensive enough to release the patch generally?
--
Vernon Cole
(adodbapi maintainer)
Post by Adrián Panella
Hi, I'am trying to use adodbapi to wrap a connection to an .accdb MS Access database and I'm getting an error when executing a query with a date parameter.
For what I could deduce the problem is that it converts to COMDate only if "settings_known" is set, which seems not to be the case for Access querys, and defaults to assuming that the parameter is a string even if it is a datetime object.
197 p.Value = dateconverter.COMDate(value)
198 else: #probably a string
This works but it is not very portable as it requires to change library code on each installation.
Any suggestions?
I have also tried running it as a stored procedure (with callproc), but in that case it tries to retrieve paramenter information (cmd.Parameters.Refresh). Which it does without error but getting all blanks. So it doesnÂŽt work either.
Thanks
_______________________________________________
python-win32 mailing list
https://mail.python.org/mailman/listinfo/python-win32
Loading...