mxODBC puzzle
M.-A. Lemburg
mal at lemburg.com
Tue Apr 29 16:44:43 EDT 2003
Bill Witherspoon wrote:
> I've been fooling around with mxODBC/mxDateTime for a couple of days
> now, trying to effect an Update query. Can anyone spot the error I'm
> making with the code below:
>
>
> sql = "Update tblOEOrders set tblOEOrders.ScheduleDate = #" +
> newdate.strftime("%m/%d/%Y") + "# where tblOEOrders.OrderID = " +
> str(orderid) + ";"
>
> myconn = mx.ODBC.Windows.Connect('production')
> mycursor = myconn.cursor()
> numlines_affected = mycursor.execute(qrystring)
This should read:
mycursor.execute(...)
numlines = mycursor.rowcount
> The DB is Access97 via DSN (which is *not* read only), and query seems
> to return OK (1 record affected), but the record never gets updated.
> Using the same code I can do Selects without difficulty.
> Do I have to do a fetchall() equivalent to make the update query run, or
> is something else wrong?
mxODBC defaults to transactional operation. To see the updates
in the database you have to commit your work, i.e. call
myconn.commit()
HTH,
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Apr 29 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
EuroPython 2003, Charleroi, Belgium: 56 days left
More information about the Python-list
mailing list