Python 我怎样才能在postgres中找到缺失的表格

Python 我怎样才能在postgres中找到缺失的表格,python,postgresql,Python,Postgresql,我正在使用python psycopg2库在postgres数据库中创建一个表: self.conn=pg.connect(host='localhost',user='eba',password='****',database='eba') cur=self.conn.cursor() cur.execute(sql) cur.close() sql='''CREATE TABLE public.tempimport ( id integer NOT NULL DEFAULT nextval

我正在使用python psycopg2库在postgres数据库中创建一个表:

self.conn=pg.connect(host='localhost',user='eba',password='****',database='eba')
cur=self.conn.cursor()
cur.execute(sql)
cur.close()

sql='''CREATE TABLE public.tempimport (
id integer NOT NULL DEFAULT nextval('tempimport_id_seq'::regclass),
tablename character varying(32) COLLATE pg_catalog."default",
    index_ character varying(32) COLLATE pg_catalog."default",
    CONSTRAINT tempimport_pkey PRIMARY KEY (id)
)
WITH (

OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE public.tempimport
    OWNER to eba;'''

cur=self.conn.cursor()
cur.execute(sql)
cur.close()
之后,如果我运行:

cur=self.conn.cursor()
cur.execute("SELECT count(*) FROM pg_catalog.pg_tables where tablename = 'tempimport'")
x=cur.fetchall()
print x
我得到1作为答案,也就是说,表存在

但是,如果我使用pgAdmin登录相同的数据库/user/pwd并运行相同的SELECT COUNT(*)。。。我得到的答案是0

我用代码创建的表在哪里


如何查找它的位置?

尝试使用信息模式:

SELECT * 
FROM information_schema.tables 
WHERE table_name = 'tempimport'

也许你还需要一个
commit
。谢谢,就这样。比我想承认的要多。