1. 程式人生 > >pandas讀取MySql數據

pandas讀取MySql數據

pan ldb passwd log lec sql word mysqld pass

用過的東西總是會忘記,尤其是細節,還是記下來比較靠譜。

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數據