[DB-SIG] Re: [Tutor] mysql formatting

Andy Dustman farcepest at gmail.com
Wed Nov 3 22:46:26 CET 2004


On Wed, 03 Nov 2004 15:41:52 -0500, Lloyd Kvam <pythontutor at venix.com> wrote:
> I checked our programming.  We add the %  for like to the parameter!

1) Use %s for all parameter placeholders, regardless of type.

1a) You can use %(key)s for a placeholder if you pass a dictionary as
the parameters.

2) Do not put additional quotes around the placeholder.

3) Do not use placeholders for things like table or column names; they
only work for column values.

4) If you use % anywhere in your query (i.e. x LIKE 'foo%'), you must
double it (%%, i.e. x LIKE 'foo%%'); it is not necessary to do this to
your parameter values.

https://sourceforge.net/forum/forum.php?thread_id=1075920&forum_id=70461

http://cvs.sourceforge.net/viewcvs.py/*checkout*/mysql-python/MySQLdb/doc/MySQLdb.txt?rev=HEAD
-- 
Computer interfaces should never be made of meat.


More information about the DB-SIG mailing list