如何使用 psycopg2 在 postgres 中获取表格? [英] How do I get tables in postgres using psycopg2?
本文介绍了如何使用 psycopg2 在 postgres 中获取表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能解释一下我如何获取当前数据库中的表?
Can someone please explain how I can get the tables in the current database?
我使用的是 postgresql-8.4 psycopg2.
I am using postgresql-8.4 psycopg2.
推荐答案
这对我有用:
cursor.execute("""SELECT table_name FROM information_schema.tables
WHERE table_schema = 'public'""")
for table in cursor.fetchall():
print(table)
这篇关于如何使用 psycopg2 在 postgres 中获取表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文