美文网首页我爱编程
读取mysql数据到pandas的DataFrame

读取mysql数据到pandas的DataFrame

作者: 沐辰老爹 | 来源:发表于2018-02-11 16:03 被阅读0次

首先还是安装必要的库

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

    本文链接:https://www.haomeiwen.com/subject/xszktftx.html