首页 > 代码库 > pandas读取MySql数据

pandas读取MySql数据

用过的东西总是会忘记,尤其是细节,还是记下来比较靠谱。

1 import MySQLdb
2 import pandas as pd
3 
4 conn = MySQLdb.connect(host = host,port = port,user = username,passwd = password,db = db_name)
5 
6 df = pd.read_sql(select * from table_name,con=conn)
7 
8 conn.close() 

很简单,有木有

pandas读取MySql数据