psycopg2 for insertion of binary data to PostgreSQL database
Graeme Glass
graemeglass at gmail.com
Mon Aug 23 04:42:23 EDT 2010
On Aug 23, 9:37 am, Julia Jacobson <julia.jacob... at arcor.de> wrote:
> How can I assign the result of a SQL query to a variable?
> The following code snippet doesn't work:
> query_result=cur.execute("SELECT column_name FROM table_name WHERE
> my_variable = 'my_value'",)
>
> > Thomas Jollans wrote:
>
>
>
> > * get the record you're interested in
You need to go and fetch the data now.
query_result.fetchone()
Take a look at the docs here, on how to fetch one vs many rows
(fetchmany)
http://initd.org/psycopg/docs/cursor.html#cursor.fetchone
hth,
Graeme
More information about the Python-list
mailing list