calling Postgresql stored procedure (written in plpython)

Nikita the Spider NikitaTheSpider at gmail.com
Fri Jun 1 16:29:30 CEST 2007


In article <1180685023.802141.168680 at h2g2000hsg.googlegroups.com>,
 Alchemist <alextabone at gmail.com> wrote:

> Thanks for your help.
> 
> My stored procedure is written in pythonpl.  I noticed that SELECT
> queries are executed correctly (results are returned to my script)
> whereas UPDATE queries are not being performed as the data is not
> updated.

Aha! So the problem is not really with how to call Postgres stored 
procs, but that you're not getting the results you expect from some 
calls. 

> I am using a database user with read/write access to the database.
> 
> Is there a commit statement in plpython?  (e.g. plpy.commit())

Did you try that? Did you check the documentation?

> Why are UPDATEs failing?

I'm not familiar with plpy but if it is compliant with the Python DBAPI 
(PEP 249) specification then, yes, it has a .commit() method and yes, 
you must call it after DDL statements. 

>From the PEP: "Note that if the database supports an auto-commit 
feature, this must be initially off."
http://www.python.org/dev/peps/pep-0249/

In short, either turn on autocommit or start calling .commit().

-- 
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more



More information about the Python-list mailing list