Julia Jacobson 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'",)

To retrieve an image from a table "images" by its name you could do 
(untested):

name = "image001.jpg"
row = cur.execute("select image from images where name = %s", 
(name,)).fetchone()
if row is None:
    raise ValueError("no image %r found" % name)
image = row[0]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to