jangbagu / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

Passing datetime.date returns TypeError: Wrong Type #50

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Insert Row into a date column with datetime.date

What is the expected output? What do you see instead?
Using pyodbc with Python2.7 it works.
I've updated all my code to 3.4 and when using pypyodbc I get the following:
  File "\pypyodbc.py", line 1470, in execute
    self._BindParams(param_types)
  File "\pypyodbc.py", line 1431, in _BindParams
    dec_num, ADDR(ParameterBuffer), BufferLen,ADDR(LenOrIndBuf))
ctypes.ArgumentError: argument 7: <class 'TypeError'>: wrong type

What version of the product are you using? On what operating system?
Python 3.4.1
pypyodbc 1.3.3
OpenEdge Database
Windows 7

Please provide any additional information below.

I've traced the issue to where on line 1431 of the pypyodbc.py its trying to 
process the datetime.date object and it throws the error.

The column I'm inserting into shows in the cursor_description as:
('create-date', <class 'datetime.date'>, 10, 10, 10, 0, True)

Regards,

Original issue reported on code.google.com by john.mar...@gmail.com on 15 Aug 2014 at 11:26

GoogleCodeExporter commented 8 years ago
Are you sure the DB column is defined as 'date' (not datetime).  I had a 
similar issue, solved by changing the type from Datetime.date to 
Datetime.datetime, consistent with the database definition (MySQL, in my case).

Original comment by marc.van...@gmail.com on 15 Sep 2014 at 11:26

GoogleCodeExporter commented 8 years ago
I'm not sure how to check further, I did try passing the Datetime.datetime and 
it gives back ('22008', '[22008] [DataDirect][ODBC Progress OpenEdge Wire 
Protocol driver]Datetime field overflow. Error in parameter 10.')

Looking at the OpenEdge documents, they mention the ODBC date type is 
SQL_TYPE_DATE. I tried a bunch of variations, even the date literal recommended 
by OpenEdge of {d 'yyyy-mm-dd'}.

Original comment by john.mar...@gmail.com on 22 Sep 2014 at 10:50