Re: PL/Python - Execute return results

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Dean Grubb <dean(at)cordeth(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/Python - Execute return results
Date: 2008-09-22 06:26:06
Message-ID: 48D73A7E.9030400@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Dean Grubb wrote:
> 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?

I'm surprised to find you directly accessing attributes but reading
the documentation I see that plpy does not support db api 2.0 style
so things are a little bit different.

Did you test: if rv: ? I think this should work because in python
empty lists (and result sets) would compare to False.

Cheers
Tino

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dave Page 2008-09-22 07:30:00 Re: [HACKERS] macport for libpqxx
Previous Message Troy Rasiah 2008-09-22 06:04:40 Query not using index