Passing variable to SQL statement when using psycopg2

2010-08-30 Thread Julia Jacobson
Dear python users, For passing a variable to a SQL query for psycopg2, I use: my_var = xyz print cur.mogrify(SELECT my_values FROM my_table WHERE my_column = %s,(my_var,)) This returns: SELECT my_values FROM my_table WHERE my_column = E'xyz' Where does the E in front of 'xyz' come

Re: Passing variable to SQL statement when using psycopg2

2010-08-30 Thread Chris Rebert
On Sun, Aug 29, 2010 at 11:29 PM, Julia Jacobson julia.jacob...@arcor.de wrote: Dear python users, For passing a variable to a SQL query for psycopg2, I use:   my_var = xyz   print cur.mogrify(SELECT my_values FROM my_table WHERE my_column = %s,(my_var,)) This returns:   SELECT

Re: Passing variable to SQL statement when using psycopg2

2010-08-30 Thread Gregory Ewing
Chris Rebert wrote: On Sun, Aug 29, 2010 at 11:29 PM, Julia Jacobson Where does the E in front of 'xyz' come from? It's probably the reason, why my query doesn't work. Quite doubtful, considering the example in the psycopg2 docs also has the E: