hannu at krosing
Mar 31, 2012, 7:04 AM
Post #5 of 6
On Sun, 2012-04-01 at 00:44 +1100, Ben Finney wrote:
Re: Using Cython for developing a module to be used from postgreSQL/pl/python
[In reply to]
> Hannu Krosing <hannu [at] krosing> writes:
> > Has anyone used Cython for developing a module to be used from
> > postgreSQL/pl/python.
> > Something that calls back to PostgreSQL internals.
> Are you aware that PostgreSQL has long provided Python as a language for
> writing stored procedures in the database?
> Does that meet your needs?
Sure, I have even contributed code to it ;)
But what i want is some way to call _back_ into PostgreSQL to use its
internal functions from a module imported from pl/python.
I tried ctypes module and got a segfault when i used the following
create or replace function callback_to_postgres(rn_text text)
from ctypes import *
pg = cdll.LoadLibrary('/usr/lib/postgresql/9.1/bin/postmaster')
select send_raw_notice('do you see me?');
I determined that the call to pg.pq_flush() was the one crashing the
backend, so I assume that cdll.LoadLibrary did not get the already
running backend, but loaded another copy of it as library.
Now I'm looking for a simplest way to do some C-wrapping. I have used
Cyuthon for wrapping simple library calls and I really don'r think there
would be hard problems doing this inside the postgreSQL extension build
I was just hoping that someboduy had already taken care of all the
nitty-gritty detaiuls of setting this up
PostgreSQL Unlimited Scalability and Performance Consultant
PG Admin Book: http://www.2ndQuadrant.com/books/
Python-Dev mailing list
Python-Dev [at] python