[DB-SIG] Running a Python script against an embedded mySQL server.

Chris Cogdon chris at cogdon.org
Wed Jul 2 12:00:24 EDT 2003


On Wednesday, Jul 2, 2003, at 10:42 US/Pacific, quadric at primenet.com 
wrote:

> Hi,
>
> I have an application that has an embedded/extended Python 
> interpreter.  I need to add
> database capabilities and for reasons to lengthy to explain in this 
> email, also require
> an embedded database server.  I have tentatively chosen mySQL 4.0 due 
> to the apparent
> ease of embedding, along with it having all the necessary database 
> functionality I need.
>
> The application executes Python expressions as well as running 
> complete Python scripts
> via its embedded interpreter.  These scripts require database access 
> to do their job.  I know
> I can connect them to an external stand-alone mySQL server.
>
> The question is,  using mySQLdb , can I connect external Python 
> scripts that the application
> executes  to the embedded mySQL server ?
>
> If so, are there any special considerations in doing this?
>
> I am experienced with relational databases and Python but
> I'm new to mySQL & mySQLdb so this is a bit of a newbie question.

The usual chain of libraries between the python application and the 
database goes like this:

[Python App.py] - [Python DB-API.py] - [db-client-wrapper.o] - 
[db-client.o]

(.o means binary files)

In your application, your application will have a combination of .py 
and .o as the 'application' in this chain. Now, to do what you need, 
all you'll need to do is to make sure that the db-client-wrapper is 
also embedded into your application. When the python db-api calls the 
lower level interface to do the actual database work, it'll just be 
executing code inside the application, which should work just fine.

Albeit, I've never heard of a full DMBS being embedded into the 
application, since the application and DMBS usually talk via a IP or 
UNIX socket... but... that's immaterial to your question :)


-- 
    ("`-/")_.-'"``-._        Chris Cogdon <chris at cogdon.org>
     . . `; -._    )-;-,_`)
    (v_,)'  _  )`-.\  ``-'
   _.- _..-_/ / ((.'
((,.-'   ((,/   fL




More information about the DB-SIG mailing list