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
评论列表
文章目录