2

I have a local postgres database. I am trying to run a simple comment on command with connection.execute. For example,

import sqlalchemy as sa
db_url = DB_URL
db_engine = sa.create_engine(db_url)
conn = db_engine.connect()

conn.execute('create schema test')
conn.execute('create table test.testing as (select 1 as value)')

conn.execute("comment on table test.testing is 'this is my table'")

This actually does create a table test.testing in my local db, but when I run the following:

select * 
from pg_description
join pg_class
on pg_description.objoid = pg_class.oid
join pg_namespace
on pg_class.relnamespace = pg_namespace.oid
where pg_namespace.nspname = 'test'
and pg_class.relname = 'testing' 

No rows are actually returned.

Vincent
  • 7,808
  • 13
  • 49
  • 63
  • 3
    Did you commit? – univerio Apr 28 '17 at 18:46
  • Ah no I did not. So that's interesting. So after committing I do see the comment. But how come without the commit, the table still gets created? As in, I'm confused why the table gets created without the commit but the comment does not get created. – Vincent Apr 28 '17 at 20:16

0 Answers0