odbc script
Chris
splungent at aol.com
Mon Dec 20 23:09:27 EST 2004
Thanks Benji,
I took your advice and added in the conn.commit() into
the script but still had the same problem. I did some digging around the
odbc documentation and found this bug:
**************************************************************************************************************
4. Hirendra Hindocha also reports: inserting a single row into a table
doesn't work properly unless one specifically deallocates the cursor.
for example the following code snippet -
conn = odbc.odbc(str)
cur = conn.cursor()
sql = 'insert into abc_table values(1,2,'abc')
cur.execute(sql)
conn.commit()
cur.close()
conn.close()doesn't work, unless you add the following lines
cur = None
conn = None at the end of the above code snippet. Tracing with ODBC and a
look into odbc.cpp shows that sqlfreestmt is not being called until the
explicit deallocation is done. [Note however, Bill Tutt seems to think that
this problem implies a problem with the specific ODBC driver, rather than
with the ODBC implementation of Python. I haven't a clue!]
*****************************************************************************************************************
I figured what the heck and added in the 2 lines specified:
cur = None
conn = None
and sure enough it worked after that! I am not sure why but figure that
when the last loop goes through it is as if it is updating 1 single row?????
Either way it works now. Thanks for the help as I am sure I needed the
conn.commit() as well.
Chris
"Benji York" <benji at benjiyork.com> wrote in message
news:mailman.8037.1103465926.5135.python-list at python.org...
> Chris wrote:
>> what ever is the last loop through doesn't seem to update the
>> database?
>
> Try a conn.commit() after your loop.
> --
> Benji York
More information about the Python-list
mailing list