database.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:pgreaper 作者: vincentlaucsb 项目源码 文件源码
def read_pg(sql, conn=None, **kwargs):
    ''' Read a SQL query and return it as a Table '''

    cur = conn.cursor(cursor_factory=extras.RealDictCursor)
    cur.execute(sql)

    # Error occurs if a function is used in SQL query
    # and column name is not explictly provided
    new_table = Table(name='SQL Query', dialect='postgres')
    new_table.add_dicts(list(cur))

    return new_table
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号