views:

77

answers:

2

Hi everyone!

I have to save some data into MySQL from Python.

I have tried MySQLdb, but it needs to be built. Build fails on my Mac; moreover, I need to have one file to copy to server. I don't have access to install anything.

Can you recommend me any solution, please! Even where I can find MySQLdb build for specific platforms.

Thanks in advance!

+1  A: 

I find the easiest way to use C extensions from python on a Mac is to use Macports

Yo will need to install macports and then install the port py26-mysql this will install python 2.6 and MySQL.

However in this case I would have thought MySQLdb should be an easy install - to help with that can you edit your question to show the error and tell us where the mySql libraries are installed

Mark
it doesn't solve the problem on server.
mxg
Can you give the actual error message and what file do you need to copy to the server - python mysql does not need more that a working MySQL on the server
Mark
+2  A: 

MySQL has a command line interface (similar to psql from Postgres or sqlite3 from the database of the same name). I would be surprised if this wasn't installed on the same server already.

You could then generate input for that utility using Python and call it with subprocess. Depending on the data, this can be as simple as generating INSERT commands from scratch, or you can generate a temporary input file (e.g. in CSV format) and pass it to the utility by name.

Peter Hansen
Temporary accepted. Switching to Perl.
mxg