Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Last active May 4, 2017 05:07
Show Gist options
  • Save Everfighting/563b4ff892f44f4d7d1f159a8282e060 to your computer and use it in GitHub Desktop.
Save Everfighting/563b4ff892f44f4d7d1f159a8282e060 to your computer and use it in GitHub Desktop.
python操作mysql数据库
# -*- 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