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()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to