1. 程式人生 > >Python3 pymsyql 連接讀取數據

Python3 pymsyql 連接讀取數據

mys sel use set OS highlight 取數 pre 讀取數據

import pymysql

conn = pymysql.connect(host=‘localhost‘, port=3306, user=‘root‘, passwd=‘root‘, db=‘test_db‘,charset=‘utf8‘)

cur = conn.cursor()

cur.execute("select * from users")

# print(cur.description)

# print()

for row in cur:
    print(row)

cur.close()
conn.close()

  

Python3 pymsyql 連接讀取數據