passing variables to Oracle via mxODBC
adavidow at my-deja.com
adavidow at my-deja.com
Wed Oct 4 13:02:58 EDT 2000
In article <39DB0CCC.DFD1F4F5 at infercor.no>,
Paul Boddie <paulb at infercor.no> wrote:
> Roeland Rengelink wrote:
> >
> > cursor.execute seems to take a string as argument. The way to tell
> > Python to replace part of a string with the values of variables is
by
> > using the %
> > operator.
> You would be better off using the parameter passing features of
mxODBC:
>
> cursor.execute("""
> insert (mystring,mydate) into bar.test values
> (:1 ,TO_DATE(:2,'YYYY-MM-DD HH:MI:SS'))
> """, (foo, str(now)))
Thanks! Indeed, I wish I had explored the parameter passing yesterday.
The TO_DATE seemed to bury things a level deeper than I was figuring
out how to parse, so I ended up constructing the entire TO_DATE(..,..)
statement using "prefix" and "postfix" strings attached to my variable,
and then embedded =that=.
I'll be curious to see if I encounter similar problems with this method
in today's programming.
ari
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list