Magnus Lycka wrote:
> Vittorio wrote:
> Using the same symbol for both string substitutions and SQL placeholder
> such as pysqlite 1 and the MySQL interface does, is not really a bright
> idea in my opinion. Who thinks this is pretty?
> 
> sql = "SELECT %s FROM %s WHERE %s = %%s"
> cur.execute(sql % (col,table,search_col), (param,))
> 
> I think it's less confusing with:
> 
> sql = "SELECT %s FROM %s WHERE %s = ?"
> cur.execute(sql % (col,table,search_col), (param,))
> 
or you could use:

   sql = "SELECT %s FROM %s WHERE %s = %s"
   cur.execute(sql % (col,table,search_col, '%s'), (param,))

which I like better, because you don't have to read
extremely carefully for the double-percents.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to