On Sun, 06 Jan 2013 16:44:47 -0500, Mitya Sirenef wrote: > On Sun 06 Jan 2013 04:38:29 PM EST, andydtay...@gmail.com wrote: >> Hi all, >> >> I'm trying to create a process which will create a new table and >> populate it. >> >> But something is preventing this from working, and I don't know enough >> to figure it out, despite having spent most of today reading up. The >> code executes with no error, yet no table is created or populated. >> >> Can anyone offer me some advice? code below. >> >> Thanks, >> >> Andy >> >> #!/usr/bin/python import psycopg2 import sys >> >> def main(): >> db = psycopg2.connect( >> host = 'localhost', database = 'gisdb', user = 'postgres', >> password = 'L1ncoln0ut@' >> ) >> cursor = db.cursor() >> cursor.execute("CREATE TABLE test (id serial PRIMARY KEY, num >> integer, data varchar);") >> cursor.execute("INSERT INTO test (num, data) VALUES (%s, %s)",(100, >> "abc'def")) >> >> if __name__ == "__main__": >> main() > > > To commit a transaction, you need to do a db.commit() call.
Or set autocommit = True on the database connection object -- http://mail.python.org/mailman/listinfo/python-list