0
In [50]: cur.execute('create table xyzabcd (c1 integer, c2 text)')
Out[50]: <pgdb.pgdbCursor at 0x344ed501d0>

But in psql if I try \dt, I cannot see the table. If I copy paste the exact same query into psql, the table is created. Then if I try to execute the above in Python, I get a ProgrammingError: ERROR: relation "xyzabcd" already exists.

Same story goes with inserts. SELECTs work flawlessly though. I've tried the same on another Postgresql server as well (both on RDS)

Any clue what might be going on? I'm connecting to via the same credentials in both psql and Python-pygresql.

Before anyone asks, I cannot use Psycopg2 because of license issues.

Postgresql Server 9.3.3, psql 9.3.5, Pygresql 4.1.1

2
  • Have you committed the transaction? Commented Nov 18, 2014 at 10:17
  • 9.3.3 has a very serious replication bug, upgrade immediately. Commented Nov 18, 2014 at 10:31

1 Answer 1

1

You must use commit() method of your dbconnection. In PostgreSQL all DDL (CREATE TABLE) are in transaction. In Python DB API 2 autocommit is off by default.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.