psql.py 文件源码

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

项目:ravel 作者: ravel-net 项目源码 文件源码
def default(self, line):
        "Execute a PostgreSQL statement"
        try:
            self.db.cursor.execute(line)
        except psycopg2.ProgrammingError, e:
            print e
            return

        try:
            data = self.db.cursor.fetchall()
            if data is not None:
                names = [row[0] for row in self.db.cursor.description]
                print tabulate.tabulate(data, headers=names)
        except psycopg2.ProgrammingError:
            # no results, eg from an insert/delete
            pass
        except TypeError, e:
            print e
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号