首先还是安装必要的库
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就是你想要读取的数据
网友评论