mxODBC puzzle

Bill Witherspoon billw at witherspoon-design.com
Tue Apr 29 23:16:23 EDT 2003


Thanks guys, I read that in the docs but had assumed that it didn't
apply to my situation, because I (foolishly) thought Access doesn't
support transactions. I thought the instruction was for more 'full
featured' databases!

(I may have had the blinders on - the project I'm working on is a
prototype to prove we can transition away from MS exclusive technologies
like Access. If I'm successful we may migrate from Access Db/Apps to
Python/WxPython with mxODBC (religion neutral) to some DB that
scales a bit better)

Thanks again,
Bill.


* M.-A. Lemburg wrote:
> 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
* M.-A. Lemburg wrote:
> 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
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
Listen, you big, stupid space-creature.  Nobody, but nobody, eats the
Simpsons!

       		-- Homer Simpson
		   Treehouse of Horror





More information about the Python-list mailing list