SQL Query via python
Sakesun Roykiattisak
sakesun at boonthavorn.com
Sat May 21 00:54:07 EDT 2005
Try
cursor.execute (
"""
SELECT name, month, day ,category, city FROM bday
WHERE %s = %s
"""
%(arg1,arg2))
Jeff Elkins wrote:
>I'm attempting to pass an SQL query via the console:
>
>$ ./getbd month 05
>
>The arguments get seem to passed correctly (via print statements) and then:
>
> cursor.execute ("""
> SELECT name, month, day ,category, city FROM bday
> WHERE %s = %s
> """,(arg1,arg2))
>
>No results. However, if I hardcode the WHERE argument with a field name:
>
> cursor.execute ("""
> SELECT name, month, day ,category, city FROM bday
> WHERE month = %s
> """,(arg2))
>
>It works.
>
>How can I code the left side of the WHERE clause so I can pass an arbitrary
>field name to search on?
>
>
>Thanks,
>
>Jeff Elkins
>
>
>
>
More information about the Python-list
mailing list