a question about mysqldb

Eric Wertman ewertman at gmail.com
Thu Aug 14 20:39:08 CEST 2008

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 argument tuple to execute (1,)

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'



I've not encountered that argument style before.

More information about the Python-list mailing list