Python读取mysql数据

使用模块pandas,pymysql

# -*- coding: utf-8 -*-
import pandas as pd
import pymysql

dbconn = pymysql.connect(
    host = "IP",
    database = 'mysql',
    user = 'root',
    password = '******'
    )
sql = 'select * from user'
a= pd.read_sql(sql,dbconn)
b = a.head()
print(b)

 

你可能感兴趣的:(Python)