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 南京市棲霞區