Created
September 22, 2015 06:22
-
-
Save swshan/f42bf7dfe82cc3c317f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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="localhost", #host | |
user="john", # username | |
passwd="megajonhy", #password | |
db="jonhydb") | |
# you must create a Cursor object. It will let you execute all the queries you need | |
cur = db.cursor() | |
# Use all the SQL you like | |
cur.execute(SELECT * FROM YOUR_TABLE_NAME) | |
# print the first cell of all the rows | |
for row in cur.fetchall(): | |
print row[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment