Python and MySQL
Gerhard Häring
gh at ghaering.de
Thu Nov 3 10:57:34 EST 2005
Thomas Bartkus wrote:
> [some posters having the idea that MySQLdb works without a C extension]
> Okay - I neglected to look at the [site-packages] directory itself. Here I
> do find [_mysql.pyd] full of binary code. A MySQLdb related file that
> doesn't seem to have a corresponding file with Python source code. Mea
> culpa! This is on MS Windows [C:\Python23].
>
> But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
> Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
> there are other file extensions, everything seems to have a corresponding
> [.py].
MySQLdb is based on a C extension module called _mysql on all platforms.
The C extension modules have the extension ".pyd" on Windows by default,
and ".so" on Unix.
It would in theory be possible to do without a C extension, but then you
would have to implement the MySQL client-server protocol
(http://dev.mysql.com/doc/internals/en/client-server-protocol.html) in
Python, for example using the socket module.
Implementing a pure-Python package to interface a database by
implementing the client-server protocol in Python has been done already
for PostgreSQL, but I don't think it has been done for MySQL, yet.
-- Gerhard
More information about the Python-list
mailing list