[mod_python] Re: error while inserting data

Joshua Ginsberg listspam at flowtheory.net
Mon Jan 9 11:21:25 EST 2006

I certainly hope Oracle requires single ticks around your strings...
wouldn't you want ('%s', '%s', '%s')? And this doesn't even try to
account for what happens if your strings have single ticks in them...

I know the MySQLdb driver handles this gracefully... you provide the
string with %s'es for variables and then provide a second argument that
is an n-tuple with the values for substitution. It surrounds strings
with single-ticks, doubling when necessary, and leaves un-ticked data
(e.g. int, double) alone without ticks.



On Mon, 2006-01-09 at 17:02 +0100, Daniel Nogradi wrote:
> Inserting variables of type string into other strings goes like this:
> name = "John"
> formatted_string = "your name is: %s" % name
> or with more variables:
> name = "John"
> age = "13"
> formatted_string = "your name is: %s and your age is: %s" % ( name, age )
> Thus you should have:
> (firstname,middlename,lastname) VALUES (%s, %s, %s)" %
> (fname,mname,lname) )
> Note the % sign.
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list