Hi there, I'm trying to connect to a PostGIS database (which is basically an enriched PostgreSQL database) and I'm having trouble with the INSERT statement. Here's my code:
import psycopg2 try: conn = psycopg2.connect("dbname='postgis' user='fdi' host='localhost' password='fdi'"); print "Database connection established" except: print "Critical Error: Unable to connect to the database" cur = conn.cursor() cur.execute("""INSERT INTO fdi.fdiresults (grid, index) VALUES (POINT(1, 1), 1)""")
It does sucessfully connect to the database (as per the program output) but when I query the database using the pgAdmin III SQL Query feature, I get no returned rows. I use the following SQL code to query:
SELECT * FROM fdi.fdiresults;
I even refresh the database but still nothing is returned. There is not traceback error given by Python either.
The following SQL statement working in the Query Editor from pgAdmin:
INSERT INTO fdi.fdiresults (grid, index) VALUES (POINT(1, 1), 1);
So since my SQL seems to be working, I don't see why my code isn't working. Can someone please give me a few suggestions?