Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with…I need to work with the stock version of Python that shipped with Leopard.
Share
Why not install a user (non-system) copy of MySQLdb?
These are the files you’d need to install:
Even if you can’t install into /usr/lib and /usr/share/pyshared, you could install it anywhere else, as long as it is in a directory listed in the client’s PYTHONPATH.
If installing a user copy of MySQLdb is for some reason not an option, then you could do the following, though be warned: it’s a horrid way to interact with mysqld for reasons that I list below:
Open up a terminal and type something like
If this works, then you could use python’s
subprocessmodule to callmysqlcommands (such as the one above).For example,
As mentioned above, you lose a lot by doing this. Namely,
retvalis just a giant string. You lose all the information about where fields and records begin and end,