Skip to content

Instantly share code, notes, and snippets.

@agneym
Created April 3, 2016 16:09
Show Gist options
  • Save agneym/857ff47fc70e543b6092410f26cd5492 to your computer and use it in GitHub Desktop.
Save agneym/857ff47fc70e543b6092410f26cd5492 to your computer and use it in GitHub Desktop.
import MySQLdb
# Open database connection
db = MySQLdb.connect("localhost","root","","dbName" )
# prepare a cursor object using cursor() method
cursor = db.cursor()
# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print "Database version : %s " % data
# disconnect from server
db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment