Sharing database connection from C to Python

Discussion in 'Python' started by dgiagio@gmail.com, Jan 30, 2006.

  1. Guest

    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
    , Jan 30, 2006
    #1
    1. Advertising

  2. wrote:
    > 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
    Daniel Dittmar, Feb 1, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Atif Jalal

    Database connection sharing

    Atif Jalal, Aug 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,891
    Steve C. Orr, MCSD
    Aug 8, 2003
  2. David Dvali

    Sharing DB connection

    David Dvali, Jul 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    403
    Kevin Spencer
    Jul 13, 2005
  3. Mythran
    Replies:
    5
    Views:
    4,942
    Mythran
    Oct 5, 2005
  4. Mike P2
    Replies:
    4
    Views:
    354
    Eliyahu Goldin
    Jun 3, 2007
  5. Andrew DeFaria
    Replies:
    7
    Views:
    324
    Tad J McClellan
    Apr 2, 2008
Loading...

Share This Page