读取mysql数据到pandas的DataFrame

首先还是安装必要的库

pip install mysql-connector-python-rf
conda install pandas
conda install sqlalchemy

好了,下面贴代码

engine = create_engine('mysql+mysqlconnector://[user]:[pass]@[host]:[port]/[db]', echo=False)
cnx = engine.raw_connection()
data = pd.read_sql('SELECT * FROM [table]', cnx)

好了,得到的data就是你想要读取的数据

你可能感兴趣的:(读取mysql数据到pandas的DataFrame)