Re: providing arguements to queries

Chuck Bearden <[email protected]> Mon, 29 Nov 2004 10:17:15 -0600
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
On Sun, 28 Nov 2004 10:42:12 +0100, Karsten Hilbert
<[email protected]> wrote:
[...]
> The query arguments are intended to be values for the *where*
> clause, no ?

I am inclined to agree with Karsten that query arguments are for the
WHERE clause.  To insert the names of columns to be retrieved into a
SELECT statement at runtime, I would use Python string formatting and
a helper function that returns a tuple of days of the week:

def daysOfWeek():
    <build list 'L' with range of days>
    return tuple(L)
[...]
cur.excute("Select %s from table" % (daysOfWeek()))

Chuck


-------------------------------------------------------
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/