L
len
I have tried both the pyodbc and mxODBC and with help from the ng been
able to do what I want using either. My needs are pretty basic some
simple selects and inserts.
The current problem I have hit is the database I am inserting into have
a special ODBC driver that using the files natively has an
autoincrement feature. However, through the ODBC driver the
autoincrement does not work. (The explanation I got was the creators
did not anticapate a great need for insert.) Anyway, I figured not a
problem I will just do a select on the table ordered by the ID field in
descending order and fetch the first record and do the autoincrementing
within the python program. The code , using pyodbc is as follows.
c.execute("select state_sid from statecode order by state_sid DESC")
sid = c.fetchone()
newsid = sid.state_sid + 1
This code works fine and I get what I want. My concern is that this
technique used on large files may cause problem. I really just want to
get what is the last record in the database to get the last ID used.
Is there a better way. I realize this may be more of an SQL question
but I figured I would try here first.
Len Sumnler
able to do what I want using either. My needs are pretty basic some
simple selects and inserts.
The current problem I have hit is the database I am inserting into have
a special ODBC driver that using the files natively has an
autoincrement feature. However, through the ODBC driver the
autoincrement does not work. (The explanation I got was the creators
did not anticapate a great need for insert.) Anyway, I figured not a
problem I will just do a select on the table ordered by the ID field in
descending order and fetch the first record and do the autoincrementing
within the python program. The code , using pyodbc is as follows.
c.execute("select state_sid from statecode order by state_sid DESC")
sid = c.fetchone()
newsid = sid.state_sid + 1
This code works fine and I get what I want. My concern is that this
technique used on large files may cause problem. I really just want to
get what is the last record in the database to get the last ID used.
Is there a better way. I realize this may be more of an SQL question
but I figured I would try here first.
Len Sumnler