Re: providing arguements to queries
Karsten Hilbert <[email protected]> Sun, 28 Nov 2004 10:42:12 +0100
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Message-ID | <[email protected]> |
> > is there another way to provide arguements to a query besides tuples? eg.
> > cur.excute("Select %s from table", (column))
> > becuase tuples cannot grow or shrink this is VERY limiting, i am in a
> > situation right now where i need to select a range of days of week,
> > because the length might change using a tuple is a pain.
>
> The second argument to execute() must be a sequence. You can use tuples, or
> lists, for example.
Be weary of one-element sequences, though. They tend to be
troublesome. The trick we tend to use is
if len(seq) == 1:
seq.append(seq[0])
BTW, I am not sure you are intended to do
"select %s from table", (column)
The query arguments are intended to be values for the *where*
clause, no ?
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/