Re: SQL Query via python

2005-05-24 Thread Frithiof Andreas Jensen
"Jeff Elkins" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Just as an fyi: > > In one weekend I have gone from knowing zip about SQL/Python to implementing > code on my personal server that emails info to family about birthdays and > such. Actually - http://www.pythonweb.org/ wil

Re: SQL Query via python

2005-05-23 Thread Gerhard Haering
On Mon, May 23, 2005 at 04:12:31PM +, Austyn Bontrager wrote: > How about: > > cursor.execute(""" > SELECT name, month, day ,category, city FROM bday > WHERE %(col_name)s = %%s > """ % dict(col_name=arg1), > (arg2) > ) > > The "%(col_name)s" will be replaced by n

Re: SQL Query via python

2005-05-23 Thread Austyn Bontrager
How about: cursor.execute(""" SELECT name, month, day ,category, city FROM bday WHERE %(col_name)s = %%s """ % dict(col_name=arg1), (arg2) ) The "%(col_name)s" will be replaced by normal Python string substitution, while the "%%s" will be quoted by the db

Re: SQL Query via python

2005-05-23 Thread Scott David Daniels
Steve Holden wrote: > Jeff Elkins wrote: >>... 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, da

Re: SQL Query via python

2005-05-22 Thread Steve Holden
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 >

Re: SQL Query via python

2005-05-21 Thread Jeff Elkins
Just as an fyi: In one weekend I have gone from knowing zip about SQL/Python to implementing code on my personal server that emails info to family about birthdays and such. I know I could have installed other *nix programs that would do the same thing, but so what :) Thanks so much to the folk

Re: SQL Query via python

2005-05-21 Thread Jeff Elkins
On Saturday 21 May 2005 01:32 pm, Dennis Lee Bieber wrote: > On Fri, 20 May 2005 23:57:01 -0400, Jeff Elkins > You have to remember that .execute(), using the (template, > (arg...)) format, is designed to apply suitable quoting to the > arguments. It does not parse the SQL to determine if argumen

Re: SQL Query via python

2005-05-21 Thread Jeff Elkins
On Saturday 21 May 2005 04:56 am, Heiko Wundram wrote: > Am Samstag, 21. Mai 2005 06:54 schrieb Sakesun Roykiattisak: > > Try > > > > cursor.execute ( > > """ > > SELECT name, month, day ,category, city FROM bday > > WHERE %s = %s > > """ > > %(arg1,arg2)) > > *argh* You don't do any quoting

Re: SQL Query via python

2005-05-21 Thread Sakesun Roykiattisak
*argh* You don't do any quoting of SQL-parameters, and that's more than bad! (leaves you up to the mercy of SQL-injection attacks, for example) I'm aware of the issue. But I think the one who start this question is too naive to explain anything more complex. Just give him a hint for fur

Re: SQL Query via python

2005-05-21 Thread Heiko Wundram
Am Samstag, 21. Mai 2005 06:54 schrieb Sakesun Roykiattisak: > Try > > cursor.execute ( > """ > SELECT name, month, day ,category, city FROM bday > WHERE %s = %s > """ > %(arg1,arg2)) *argh* You don't do any quoting of SQL-parameters, and that's more than bad! (leaves you up to the mercy of

Re: SQL Query via python

2005-05-20 Thread Sakesun Roykiattisak
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: > >cu