Python MySQL Module

I am developing a web application that needs to interact with a MySQL database, and I cannot find really good modules for Python.

I am specifically looking for a fast module that can handle hundreds of thousands of connections (and requests, all within a short period of time from each other), without a significant impact on speed.

+6
python mysql module
source share
4 answers

MySQLdb is almost the only game in town to access python mysql.

+7
source share

I think my answer will be an update of the playing field.

There is currently an official MysQL Python Connector.

Installation:

sudo pip install mysql-connector-python 

Or download it here:

http://dev.mysql.com/downloads/connector/python/

Documentation: http://dev.mysql.com/doc/refman/5.5/en/connector-python.html

+9
source share

I usually use SQLObject , but I did not use it in a highly stressful situation, so I could not vouch for the performance (said that I would not speak against it).

To copy the demo code from another answer:

 from sqlobject import * # Replace this with the URI for your actual database connection = connectionForURI('mysql://server:XXXX') sqlhub.processConnection = connection # This defines the columns for your database table. See SQLObject docs for how it # does its conversions for class attributes <-> database columns (underscores to camel # case, generally) class Song(SQLObject): name = StringCol() artist = StringCol() album = StringCol() # Create fake data for demo - this is not needed for the real thing def MakeFakeDB(): Song.createTable() s1 = Song(name="B Song", artist="Artist1", album="Album1") s2 = Song(name="A Song", artist="Artist2", album="Album2") def Main(): # This is an iterable, not a list all_songs = Song.select().orderBy(Song.q.name) # Do something by iterating over the song list... 
+2
source share

oursql is another option for python-mysql access. This is a much more complete libmysqlclient shell than MySQLdb. As a rule, in my experience there are many nice additional features.

+1
source share

All Articles