[DB-SIG] How to pass parameter with LIKE

Ricardo Bugalho ricardo.b at zmail.pt
Sat Nov 4 00:13:11 CET 2006


And avoid python's string formating. Use paramterized queries.

cursor.execute(
"SELECT mrc_code from blocks where mrc_code in (%s, %s, %s, %s)",
blkfld) 

You can generate that string too, instead of hard coding it:

sqlQuery = "SELECT mrc_code FROM blocks WHERE mrc_code in (%s)" %
(",").join(["%s" for x in blkfld])
cursor.execute(sqlQuery, blkfld)


On Wed, 2006-10-25 at 10:01 +0000, William Dode wrote:
> On 25-10-2006, Janice Sterling wrote:

> 
> select mrc_code from blocks where mrc_code in ('31103a1', '31103e1', 
> '31103a5', '31103e5')
> 
> isnt'it ?
> 





More information about the DB-SIG mailing list