Last active
May 4, 2017 05:07
-
-
Save Everfighting/563b4ff892f44f4d7d1f159a8282e060 to your computer and use it in GitHub Desktop.
python操作mysql数据库
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
# -*- coding: utf-8 -*- | |
import pymysql | |
conn= pymysql.connect(host="localhost",user="root",passwd="admin",db="local_db",charset="utf8") | |
cursor = conn.cursor() | |
n = cursor.execute("select * from course") | |
for row in cursor.fetchall(): | |
for r in row: | |
print (r) | |
print(n) | |
cursor.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment