2

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!

2
  • One solution I'm thinking about is to use php for database access. But this is not elegant, temporary solution. Commented Feb 2, 2010 at 13:58
  • What difference would php do - it still will copy the file to the server in the same way python does Commented Feb 2, 2010 at 17:14

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.