pandas 读取mysql"/>
pandas 读取mysql
目录
- 读取mysql的数据
- 存储数据到mysql
-
读取mysql的数据
from sqlalchemy import create_engine
import numpy as np
import pandas as pd
import pymysqlcon = pymysql.Connection(host = 'localhost',port = 3306,user = 'root',password = 666,database = 'qiubai',charset = 'utf8')
sql = 'select * from qiubai_table limit 10'
df = pd.read_sql(sql,con)
-
存储数据到mysql
# mysql+pymysql://用户名:密码@ip:端口号/数据库?charset=utf8&
engine = create_engine('mysql+pymysql://root:666@localhost:3306/qiubai?charset=utf8')
df.to_sql('qiubai_table_f',engine)
更多推荐
pandas 读取mysql
发布评论