from odps import options
import time
#project = odps.get_project()
# 表操作
#表清单
for table in odps.list_tables():
print table
#表是否存在
if odps.exist_table('ods_orders'):
print 1
else:
print 0
#获取表
odps.get_table('ods_orders',project='ah_test')
#创建表
table = odps.create_table('my_new_table','num bigint,num2 double',if_not_exists=True) #一般表
table = odps.create_table('my_new_table',('num bigint,num2 double','pt string'),if_not_exists=True) #分区表
options.sql.use_odps2_extension = True #新数据类型支持开关
#同步表更新
table.reload()
#获取表数据
table = odps.get_table('ods_orders')
with table.open_reader(partition='pt=20191118') as reader:
count = reader.count
for record in reader[5:10]:
print (record)
#写入数据
with table.open_writer(partition='pt=20191120,pt1=...',create_partition=True) as writer:
records =
PYODPS基础语法记录
最新推荐文章于 2024-05-01 10:16:31 发布