PL/Python - Execute return results

From: "Dean Grubb" <dean(at)cordeth(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PL/Python - Execute return results
Date: 2008-09-22 03:35:26
Message-ID: 539ac17c0809212035l1807349ej589e18f4ca54064d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

plan = plpy.prepare("SELECT last_name FROM my_users WHERE first_name =
$1", [ "text" ])
rv = plpy.execute(plan, [ "name" ], 5)
return rv["last_name"]

If the SELECT command does not return any results, how do I
catch/check for this?

if rv == {} ?

or maybe

try:
rv = plpy.execute(plan, [ "name" ], 5)
return rv["last_name"]
except:
...
else:
...

can't seem to get either to work.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dale Harris 2008-09-22 03:50:09 Triggers not working
Previous Message Martijn van Oosterhout 2008-09-21 15:09:59 Re: R-tree, order by, limit