Skip to content

Instantly share code, notes, and snippets.

@roblayton
Created June 6, 2015 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblayton/c3e330a7485ccb1f1296 to your computer and use it in GitHub Desktop.
Save roblayton/c3e330a7485ccb1f1296 to your computer and use it in GitHub Desktop.
A Python server for reading names from a MySQL DB
import MySQLdb
db = MySQLdb.connect(host="192.168.33.10", user="test", passwd="password", db="test")
cursor = db.cursor()
cursor.execute("SELECT firstname,lastname FROM test.name")
for row in cursor.fetchall():
firstname = str(row[0])
lastname = str(row[1])
print("Name is " + firstname + " " + lastname)
cursor.close()
db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment