Sophon notebook中Python dataframe写入写出inceptor demo

  使用配置
内容纲要

概要描述

本文主要描述Sophon notebook中Python dataframe写入写出inceptor demo。

详细说明

Sophon notebook中Python dataframe写入写出inceptor demo如下:

import sqlalchemy
import pandas as pd
from pyhive import hive
from sqlalchemy import create_engine
#建立数据库连接engine
engine=create_engine('hive://hive:123@172.22.26.6:10000/default',
connect_args={'auth':'LDAP'},)
sql_cmd="select * from result_table1"
#以dataframe类型读取inceptor表数据
df=pd.read_sql(sql=sql_cmd,con=engine)
#将dataframe类型数据写入inceptor表
df.to_sql(name="result_table2", con=engine, schema=None, if_exists='append', index=False)

注意:result_table2须为orc事务表,es,hyperbase等可以单条插入数据的表。

这篇文章对您有帮助吗?

平均评分 0 / 5. 次数: 0

尚无评价,您可以第一个评哦!

非常抱歉,这篇文章对您没有帮助.

烦请您告诉我们您的建议与意见,以便我们改进,谢谢您。