Python MySQL GitHub
Try this to connect to MySQL databases in Python (GitHub project link in source):
shell> pip install mysql-connector-python
import mysql.connector
# Connect to server
cnx = mysql.connector.connect(
host="127.0.0.1",
port=3306,
user="mike",
password="s3cre3t!")
# Get a cursor
cur = cnx.cursor()
# Execute a query
cur.execute("SELECT CURDATE()")
# Fetch one result
row = cur.fetchone()
print("Current date is: {0}".format(row[0]))
# Close connection
cnx.close()
MitchAloha