Python mysql-python
From wikinotes
WARNING:
mysql-python only supports python2. See python pymysql instead. (as a bonus, it's actually easier to install)
## Conect to Database
import MySQLdb as mb
host = root
user = will
pass = password
connectStr = 'host=%s, user=%s, passwd=%s, db=%db'
conn = mb.connect( connectStr )
c = conn.cursor()
## Fill Table
c.execute(
'INSERT INTO test(name, data) \n'
'VALUES ( "a", "1" ), \n'
' ( "b", "2" ), \n'
' ( "c", "3" ), \n'
' ( "d", "4" ) \n'
)
conn.commit()
## Query Table
ret = []
for item in c.execute( 'SELECT * FROM test WHERE name="a"' )
ret.append( item )
## Close Connection
conn.close()
print ret