Ich bin mit Python psycopg2 Bibliothek eine Tabelle in einer Postgres-Datenbank zu erstellen:Wie finde ich einen verpassten Tisch in 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()
nach der Party, wenn ich laufe:
cur=self.conn.cursor()
cur.execute("SELECT count(*) FROM pg_catalog.pg_tables where tablename = 'tempimport'")
x=cur.fetchall()
print x
ich 1 als Antwort, das heißt, die Tabelle existiert.
Wenn ich jedoch die gleiche Datenbank/Benutzer/Pwd mit pgAdmin anmelden und denselben SELECT COUNT (*) ... Satz ausführen, bekomme ich 0 als Antwort.
Wo ist die Tabelle, die ich mit Code erstellt habe?
Wie kann ich finden, wo es ist?
Vielleicht brauchen Sie einen 'commit' auch. –
Danke, das ist es! –
. . Bekommt mich viel öfter, als ich zugeben möchte. –