Re: a question about mysqldb

2008-08-14 Thread Carsten Haese
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

Re: a question about mysqldb

2008-08-14 Thread Eric Wertman
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

RE: a question about mysqldb

2008-08-14 Thread Edwin . Madari
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

Re: a question about mysqldb

2008-08-14 Thread Eric Wertman
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

Re: a question about mysqldb

2008-08-14 Thread Bruno Desthuilliers
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

RE: a question about mysqldb

2008-08-14 Thread Edwin . Madari
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

Re: a question about mysqldb

2008-08-14 Thread Fredrik Lundh
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