Skip to content

Instantly share code, notes, and snippets.

@m7shapan
Created March 6, 2017 10:20
Show Gist options
  • Save m7shapan/cfcdb5e84af7ff9ff0f3fb9b5484a14e to your computer and use it in GitHub Desktop.
Save m7shapan/cfcdb5e84af7ff9ff0f3fb9b5484a14e to your computer and use it in GitHub Desktop.
connect to MySql DB python
import MySQLdb
import MySQLdb.cursors
sql_db = MySQLdb.connect(host="",user="",passwd="",db="",cursorclass=MySQLdb.cursors.DictCursor)
cursor = sql_db.cursor()
domainsCount = cursor.execute("SELECT * FROM domains where ...")
print cursor.fetchall()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment