开发者

Python database access using single file/already build file

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, plea开发者_如何转开发se! Even where I can find MySQLdb build for specific platforms.

Thanks in advance!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜