jakesylvestre / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Using datetime.datetime objects as parameters causes Ingres ODBC error in subsequent queries #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create function get_data

def get_data(sql, params=None):

    cn = pyodbc.connect(my_connection_string)
    cursor = cn.cursor()

    if params:
        cursor.execute(sql,params)
    else:
        cursor.execute(sql)

    results = cursor.fetchall()
    columns = [ desc[0] for desc in cursor.description ]

    cn.close()

    return columns, results

2. Call function with something like:
    get_data('select * from aircraft where date_and_time_stamp between ? and ?',[datetime.datetime(2000,1,1),datetime.datetime(2011,1,1)] )

3. It will work first time.

4. Call function again as in step 2 and you get an exception (see below)

5. If you perform the same query using dates represented as strings you can 
repeat the call to the function many times with no errors.

What is the expected output? What do you see instead?
I should get the proper row of rows. I get an exception (see below)

What version of the product are you using? On what operating system?
In [10]: pyodbc.version
Out[10]: '3.0.2'

Client Windows XP SP2 with Python 2.6 

Ingres 9.00.0000

Ingres 3.0 ODBC Driver

Please provide any additional information below.

STACK TRACE:

C:\Documents and Settings\hiaprc\My Documents\CH149\HUMS - 
SUM\CH149Code\e_viz\db_layer.py in get_data(sql, params)
     15
     16     if params:
---> 17         cursor.execute(sql,params)
     18     else:
     19         cursor.execute(sql)

Error: ('5000R', '[5000R] [Ingres][Ingres ODBC Driver][Ingres]Query cannot be 
closed in the current state, it may only be cancelled. (13172743) 
(SQLExecDirectW); [22018]
 [Ingres][Ingres ODBC Driver]Error in assignment (0)')

Original issue reported on code.google.com by pchi...@gmail.com on 31 Jan 2012 at 2:20

GoogleCodeExporter commented 9 years ago
I've tried to reproduce this over the last few hours, but cannot.  I'm using:

* Ingres 10.1 32-bit
* ODBC driver: CAIIOD35.DLL 03.50.1010.0126
* pyodbc 3.0.6-beta01
* Python 2.7.2 32-bit

Is it possible for you to test with the latest version of Ingres?  It seems 
they may have fixed something.

Original comment by mkleehammer on 24 Jun 2012 at 2:13

GoogleCodeExporter commented 9 years ago
Unfortunately I am unable to test with the latest version.
It's not a show stopper so I can live with it.
Thanks for looking into this.

Original comment by pchi...@gmail.com on 24 Jun 2012 at 12:00

GoogleCodeExporter commented 9 years ago
Closing due to inactivity.  

Original comment by mkleehammer on 29 Sep 2012 at 6:11