Created
October 31, 2019 16:41
-
-
Save heylastway/e242e18cae772bcb1ec98caf99ed835d to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
import MySQLdb | |
# Connect | |
db = MySQLdb.connect(host="localhost", | |
user="appuser", | |
passwd="", | |
db="onco") | |
cursor = db.cursor() | |
# Execute SQL select statement | |
cursor.execute("SELECT * FROM location") | |
# Commit your changes if writing | |
# In this case, we are only reading data | |
# db.commit() | |
# Get the number of rows in the resultset | |
numrows = cursor.rowcount | |
# Get and display one row at a time | |
for x in range(0, numrows): | |
row = cursor.fetchone() | |
print row[0], "-->", row[1] | |
# Close the connection | |
db.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment