mysql数据库
import numpy as np
import pandas as pd
from sqlalchemy import create_engine
from pyecharts.charts import *
from pyecharts import options as opts
engine = create_engine('mysql+pymysql://root:123456@localhost:3306/db?charset=utf8')
df = pd.read_sql('select * from db.house_info', engine)
df.to_sql('表名',engine,index=Flase,if_exists='replace')
hive数据库
import pandas as pd
import pyodbc
con = pyodbc.connect('DSN=hive',autocommit=True)
df = pd.read_sql('select * from edu.score ',con=con)
df
或者
import pandas as pd
from pyhive import hive
from sqlalchemy import create_engine
con = hive.Connection(host='10.36.142.186',
port=10000,
auth="NOSASL",
database='test',
username='root')
sql = 'select * from score'
df = pd.read_sql(sql,con)
print(df)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)