python连接odps,并且通过sql进行查询,返回dataframe
from odps import ODPS
from odps import DataFrame
def exe_odps(sql, project):
'''
sql:待执行sql
project:项目空间
'''
access_id = '*****'
secret_access_key = '*****'
project = project
endpoint = 'http://service.odps.aliyun.com/api'
o = ODPS(
access_id=access_id,
secret_access_key=secret_access_key,
project=project,
endpoint=endpoint)
with o.execute_sql(sql).open_reader() as reader:
data = reader.to_pandas()
return data
2020-02-17 南京市栖霞区
来源:CSDN
作者:维格堂406小队
链接:https://blog.csdn.net/wendaomudong_l2d4/article/details/104355045