Andre' John <[EMAIL PROTECTED]> wrote: > >I am trying to do this for a Postgresql database: > >conn = psycopg2.connect('host=localhost') >cur = conn.cursor() >cur.execute("SELECT * FROM names WHERE name=%s", ['S']) > >, which doesn't work, and neither does > >cur.execute("SELECT * FROM names WHERE name='%s'", ['S'])
Psycopg requires that the parameters be passed as a tuple, not a list. Also, psycopg will do the quoting for you. You don't do it. So this is what you want: cur.execute("SELECT * FROM names WHERE name=%s", ('S',) ) Note that the extra comma is required in Python to make a one-element tuple. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list