Created
June 6, 2015 23:20
-
-
Save roblayton/c3e330a7485ccb1f1296 to your computer and use it in GitHub Desktop.
A Python server for reading names from a MySQL DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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