Re: DB-API execute params, am I missing something?

2009-05-30 Thread Lawrence D'Oliveiro
In message <55520c08-5b02-4231- b0f3-74eadecd6...@g1g2000yqh.googlegroups.com>, John Machin wrote: > ... suggest a better way. -- http://mail.python.org/mailman/listinfo/python-list

Re: DB-API execute params, am I missing something?

2009-05-29 Thread John Machin
On May 30, 11:35 am, Lawrence D'Oliveiro wrote: > In message <0dcfcb4a-8844-420b-b2e2- > > c8e684197...@p6g2000pre.googlegroups.com>, John Machin wrote: > > If you need to escape % or _ in a LIKE argument, do whatever the host > > convention is. > > E.g. you are searching for text that contains li

Re: DB-API execute params, am I missing something?

2009-05-29 Thread Lawrence D'Oliveiro
In message <0dcfcb4a-8844-420b-b2e2- c8e684197...@p6g2000pre.googlegroups.com>, John Machin wrote: > If you need to escape % or _ in a LIKE argument, do whatever the host > convention is. > E.g. you are searching for text that contains literally "5% discount", > with SQLite you could do: > [avoidi

Re: DB-API execute params, am I missing something?

2009-05-29 Thread Lawrence D'Oliveiro
In message , Dennis Lee Bieber wrote: > On Thu, 28 May 2009 20:57:13 +1200, Lawrence D'Oliveiro > declaimed the following in > gmane.comp.python.general: > >>> >>>>>> db.literal((... "%wildcard%" ...)) >>>(... "'%wildcard%'" ...) >> >> Doesn't look like it worked, does it? > > If the

Re: DB-API execute params, am I missing something?

2009-05-28 Thread Gabriel Rossetti
Paul Boddie wrote: On 26 Mai, 13:46, Gabriel Rossetti wrote: def getParams(curs): curs.execute("select * from param where id=%d", 1001) First of all, you should use the database module's parameter style, which is probably "%s" - something I've thought should be deprecated for a lo

Re: DB-API execute params, am I missing something?

2009-05-28 Thread Gabriel Rossetti
Diez B. Roggisch wrote: Gabriel Rossetti wrote: Hello everyone, I am trying to use dbapi with mysql and I get this error: Traceback (most recent call last): File "", line 1, in File "", line 2, in getUnitParams File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 151, in

Re: DB-API execute params, am I missing something?

2009-05-28 Thread Teguh Iskanto
On Fri, May 29, 2009 at 3:21 PM, Dennis Lee Bieber wrote: > >This won't work as the DB-API is going to quote the parameter, and > the final result would be '%'whatever'%'. Essentially, you must put the > wildcard marker on the actual parameter before feeding it to the API. > -- >Wu

Re: DB-API execute params, am I missing something?

2009-05-28 Thread Lawrence D'Oliveiro
In message , Dennis Lee Bieber wrote: > On Thu, 28 May 2009 13:12:57 +1200, Lawrence D'Oliveiro > declaimed the following in > gmane.comp.python.general: > >> >> What if the string you're searching for includes a "%" or "_" character? > >>>> db.literal((... "%wildcard%" ...)) >(... "'

Re: DB-API execute params, am I missing something?

2009-05-27 Thread Teguh Iskanto
On Thu, May 28, 2009 at 11:12 AM, Lawrence D'Oliveiro wrote: > In message <784h2cf1kem0...@mid.uni-berlin.de>, Diez B. Roggisch wrote: > > > Lawrence D'Oliveiro wrote: > > > >> In message , Dennis > >> Lee Bieber wrote: > >> > >>> Notice that db.literal() call? That's part of the mechanism used t

Re: DB-API execute params, am I missing something?

2009-05-27 Thread John Machin
On May 28, 11:12 am, Lawrence D'Oliveiro wrote: > In message <784h2cf1kem0...@mid.uni-berlin.de>, Diez B. Roggisch wrote: > > > Lawrence D'Oliveiro wrote: > > >> In message , Dennis > >> Lee Bieber wrote: > > >>> Notice that db.literal() call? That's part of the mechanism used to > >>> escape and

Re: DB-API execute params, am I missing something?

2009-05-27 Thread Lawrence D'Oliveiro
In message <784h2cf1kem0...@mid.uni-berlin.de>, Diez B. Roggisch wrote: > Lawrence D'Oliveiro wrote: > >> In message , Dennis >> Lee Bieber wrote: >> >>> Notice that db.literal() call? That's part of the mechanism used to >>> escape and quote parameters -- it only returns strings that are safe f

Re: DB-API execute params, am I missing something?

2009-05-27 Thread Diez B. Roggisch
Lawrence D'Oliveiro wrote: > In message , Dennis > Lee Bieber wrote: > >> Notice that db.literal() call? That's part of the mechanism used to >> escape and quote parameters -- it only returns strings that are safe for >> insertion into the SQL statement. > > Does it deal with "like"-wildcards?

Re: DB-API execute params, am I missing something?

2009-05-27 Thread Paul Boddie
On 26 Mai, 13:46, Gabriel Rossetti wrote: > > def getParams(curs): >     curs.execute("select * from param where id=%d", 1001) First of all, you should use the database module's parameter style, which is probably "%s" - something I've thought should be deprecated for a long time due to the confus

Re: DB-API execute params, am I missing something?

2009-05-27 Thread Lawrence D'Oliveiro
In message , Dennis Lee Bieber wrote: > Notice that db.literal() call? That's part of the mechanism used to > escape and quote parameters -- it only returns strings that are safe for > insertion into the SQL statement. Does it deal with "like"-wildcards? -- http://mail.python.org/mailman/listi

Re: DB-API execute params, am I missing something?

2009-05-26 Thread Diez B. Roggisch
Gabriel Rossetti wrote: > Hello everyone, I am trying to use dbapi with mysql and I get this error: > > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in getUnitParams > File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 151, > in execute > q

DB-API execute params, am I missing something?

2009-05-26 Thread Gabriel Rossetti
Hello everyone, I am trying to use dbapi with mysql and I get this error: Traceback (most recent call last): File "", line 1, in File "", line 2, in getUnitParams File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 151, in execute query = query % db.literal(args) TypeError: