Eric Wertman wrote:
This means I could use this type of syntax?
sql = 'SELECT (date,time,name,size,count,stuff,flavor) FROM crazyTable
where monster=:1 and feet=:2 and price=:3'
cursor.execute(sql,('cookie','3',77.44))
?
That depends on which database and DB-API module you're using. Numeric
Just to make sure I understand what you are showing me here:
> columns = ('tID', 'tNote')
> table_name = 'tmp'
> sql = 'select %s from %s where tID=:1' % ( ', '.join(columns), table_name)
> cursor.execute(sql, (1,))
>
> # sql is now 'select tID, tNote from tmp where tID=:1'
> # note the comma in a
l, (1,))
# sql is now 'select tID, tNote from tmp where tID=:1'
# note the comma in argument tuple to execute (1,)
thanks Edwin
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Eric Wertman
Sent: Thursday, August 14, 2008 2:13 PM
To: python-li
I also like to use escaped identifiers in cases like this:
sql = "select tID,tNote from %s where %s = %%s" % ("tmp","tID")
cursor.execute(sql,1)
should work fine.
--
http://mail.python.org/mailman/listinfo/python-list
Evan a écrit :
a simple problem but I do not know why...:(, could anyone help me?
MySQLdb nominally uses just the %s placeholder style, in my script, i
got error if you want to use placeholder(%s) for table name:
db-api placeholders won't work for table names - or for anything that
isn't supp
replace the name of table before calling *.execute.
s.dbptr.execute(str % (e[0]))
good luck.
Edwin
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
On Behalf Of Evan
Sent: Thursday, August 14, 2008 11:27 AM
To: python-list@python.org
Subject: a question about mysqldb
Evan wrote:
a simple problem but I do not know why...:(, could anyone help me?
MySQLdb nominally uses just the %s placeholder style, in my script, i
got error if you want to use placeholder(%s) for table name:
Placeholders are supposed to be used for *values*, not other parts of
the SQL stat