MaxComputer——pyodps

MaxComputer——pyodps,第1张

概述1.文档   详细文档:https://pyodps.readthedocs.io/zh_CN/latest/base-projects.html   官方文档:https://help.aliyun.com/document_detail/90412.html?spm=a2c4g.11174283.6.779.690b590ercWTA2 2.入门示例:   1.获取表结构:      impo

1.文档

  详细文档:https://pyodps.readthedocs.io/zh_CN/latest/base-projects.html

  官方文档:https://help.aliyun.com/document_detail/90412.html?spm=a2c4g.11174283.6.779.690b590ercWTA2

2.入门示例:

  1.获取表结构:

    

import sys;# 防止中文注释乱码reload(sys);sys.setdefaultencoding("utf8")# 定义表名筛选的前后缀ODS_PREFIX = ods_ODS_SUFFIX = _snapshotods_table_List = o.List_tables(project=rkk,prefix=ODS_PREFIX)for t in ods_table_List:    table_name = t.name    if table_name.endswith(ODS_SUFFIX):        # 获取表注释        table_comment = t.comment        cols = t.schema.columns        for col in cols:            col_name = col.name            col_type = col.type            col_comment = col.comment            # 将表结构写入结果表            o.execute_sql("insert into table rkk_ods_schema_all values (‘%s‘,‘%s‘,‘%s‘);" % (table_name,table_comment,col_name,col_type,col_comment))

  2.批量修改表注释

import sys;# 防止中文注释乱码reload(sys);sys.setdefaultencoding("utf8")# 需要修改表的表名table_List = o.List_tables(prefix=ods_)for t in table_List:    table_name = t.name    # 获取表注释    old_std_comment = t.comment    new_std_comment = "ods_" + old_std_comment    # 非std_开头的注释,使用sql DDL添加新注释    if not old_std_comment.startswith(ods_):        o.execute_sql("alter table %s set comment ‘%s‘;" % (table_name,new_std_comment))
总结

以上是内存溢出为你收集整理的MaxComputer——pyodps全部内容,希望文章能够帮你解决MaxComputer——pyodps所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1051311.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存