Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Using Cython for developing a module to be used from postgreSQL/pl/python

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


hannu at krosing

Mar 31, 2012, 5:22 AM

Post #1 of 6 (242 views)
Permalink
Using Cython for developing a module to be used from postgreSQL/pl/python

Hi

Has anyone used Cython for developing a module to be used from
postgreSQL/pl/python.

Something that calls back to PostgreSQL internals.


-------
Hannu Krosing
PostgreSQL Unlimited Scalability and Performance Consultant
2ndQuadrant Nordic
PG Admin Book: http://www.2ndQuadrant.com/books/

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


stefan_ml at behnel

Mar 31, 2012, 5:41 AM

Post #2 of 6 (239 views)
Permalink
Re: Using Cython for developing a module to be used from postgreSQL/pl/python [In reply to]

Hannu Krosing, 31.03.2012 14:22:
> Has anyone used Cython for developing a module to be used from
> postgreSQL/pl/python.
>
> Something that calls back to PostgreSQL internals.

Note that this is the CPython core developers mailing list, for which your
question is off-topic. Please ask on the cython-users mailing list (see
http://cython.org).

Stefan

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


hannu at krosing

Mar 31, 2012, 5:56 AM

Post #3 of 6 (235 views)
Permalink
Re: Using Cython for developing a module to be used from postgreSQL/pl/python [In reply to]

On Sat, 2012-03-31 at 14:41 +0200, Stefan Behnel wrote:
> Hannu Krosing, 31.03.2012 14:22:
> > Has anyone used Cython for developing a module to be used from
> > postgreSQL/pl/python.
> >
> > Something that calls back to PostgreSQL internals.
>
> Note that this is the CPython core developers mailing list, for which your
> question is off-topic. Please ask on the cython-users mailing list (see
> http://cython.org).

Thanks for the pointer !

Can you recommend a similar place for asking the same queston about
ctypes ?

That is using ctypes for calling back to "outer" c application which
embeds the python interpreter.

> Stefan
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev [at] python
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/hannu%40krosing.net


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


ben+python at benfinney

Mar 31, 2012, 6:44 AM

Post #4 of 6 (232 views)
Permalink
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?

<URL:http://www.postgresql.org/docs/current/static/plpython.html>

Does that meet your needs?

--
\ “You've got to think about big things while you're doing small |
`\ things, so that all the small things go in the right |
_o__) direction.” —Alvin Toffler |
Ben Finney

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


hannu at krosing

Mar 31, 2012, 7:04 AM

Post #5 of 6 (236 views)
Permalink
Re: Using Cython for developing a module to be used from postgreSQL/pl/python [In reply to]

On Sun, 2012-04-01 at 00:44 +1100, Ben Finney wrote:
> 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?
>
> <URL:http://www.postgresql.org/docs/current/static/plpython.html>
>
> 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)
returns text
language plpythonu
as
$$

from ctypes import *
import struct

pg = cdll.LoadLibrary('/usr/lib/postgresql/9.1/bin/postmaster')
pg.pq_flush()

return rn_text
$$;

select send_raw_notice('do you see me?');

<CRASHES HERE>

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
framework.

I was just hoping that someboduy had already taken care of all the
nitty-gritty detaiuls of setting this up


-------
Hannu Krosing
PostgreSQL Unlimited Scalability and Performance Consultant
2ndQuadrant Nordic
PG Admin Book: http://www.2ndQuadrant.com/books/





_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


martin at v

Mar 31, 2012, 10:45 AM

Post #6 of 6 (231 views)
Permalink
Re: Using Cython for developing a module to be used from postgreSQL/pl/python [In reply to]

> Can you recommend a similar place for asking the same queston about
> ctypes ?
>
> That is using ctypes for calling back to "outer" c application which
> embeds the python interpreter.

ISTM that Postgres lists should be the best place for this kind of question.
Alternatively, try python-list or db-sig.

Regards,
Martin


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.