What I'm trying to achieve is to create a geometry column of a point based on the latitude and longitude of that particular row in the already created table.
Given the following code:
#!/usr/local/bin/python from pysqlite2 import dbapi2 as sqlite3 conn = sqlite3.connect('adde.sqlite') conn.enable_load_extension(True) conn.execute("SELECT load_extension('libspatialite-2.dll');") conn.execute("SELECT InitSpatialMetadata();") conn.enable_load_extension(False) conn.execute("SELECT AddGeometryColumn('coords','geom_column', 4326, 'Point', 2);") conn.execute("UPDATE coords SET geom_column = GEOMETRYFROMTEXT('POINT('||longitude||' '||latitude||')', 4326);") conn.close()
I receive the error:
AddGeometryColumn() error: "insert on table 'geometry_columns' violates constraint: 'spatial_ref_sys.srid'"
I've been able to create the column in the Spatialite GUI no problem, but I'd like to do all of this programmatically using Python. I've searched for a while now and I'm coming up a bit short. Any guidance as to why I'm receiving this particular error would be greatly appreciated.
I'm using Python 2.6 and pysqlite2 on Windows 7 64-bit