MySQLdb question
Gerhard Häring
gerhard at bigfoot.de
Thu Jun 20 09:19:19 EDT 2002
In article <aesi66$cgb$1 at sunsite.icm.edu.pl>, =?Latin-2?Q?Micha=B3?= Kurowski wrote:
> Hi,
>
> I'm working on a small project involving sql (MySQLdb-0.9.1) and I constantly
> have to "get around" a quite weird problem:
>
> I cannot find a way to pass a sql statement a table as a parameter.
These are two different things:
(1) cursor.execute("... %s ...", "foo")
(2) cursor.execute("... %s ..." % foo)
(1) is the DB-API method to get proper quoting of parameters for SQL.
(2) is the normal Python quoting
For table names, you need (2), for about everything else, you need (1).
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list