Sharing database connection from C to Python

D

dgiagio

Hi,

I'm developing an application using the C language and Python for it's
plugins. The C program connects to a MySQL database and keeps that
connection active. Is it possible to 'share' this connection with the
Python plugins? If so, is there a "standard" way to do that?

Thank you.

DG
 
D

Daniel Dittmar

I'm developing an application using the C language and Python for it's
plugins. The C program connects to a MySQL database and keeps that
connection active. Is it possible to 'share' this connection with the
Python plugins? If so, is there a "standard" way to do that?

There is no simple way as MySQL connections in Python are Python
extension objects. You'll probably have to use a custom MySQL driver.

Either create the session in C and add a constructor to the python to
create a MySQL connection object from that handle or pointer

Or add a method to the Python MySQL object to get the handle and
pointer. Create all database connections in Python (precise: using the
Python API from C), get the handle and pointer to use it from C, pass
the original session to plugins.

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top