diff --git a/geopetl/oracle_sde.py b/geopetl/oracle_sde.py index 7e98fc0..2069ef7 100644 --- a/geopetl/oracle_sde.py +++ b/geopetl/oracle_sde.py @@ -590,6 +590,10 @@ def _get_srid(self): if self.geom_field is None: return None + # Someone wants to force the SRID to be detected as this. + if self.insert_srid: + return self.insert_srid + stmt = """ select s.auth_srid from sde.layers l @@ -960,6 +964,11 @@ def write(self, rows, srid=None, table_srid=None, for field in fields: type_ = type_map[field] if type_ == 'geom': + # SRID cannot be None here! This will result in this being used in the prepare statment: + #SDE.ST_GEOMETRY(:SHAPE, NONE)) + # which ends with this error: cx_Oracle.DatabaseError: ORA-00984: column not allowed here + print('Making sure we have an SRID value..') + assert self.srid, "SRID cannot be None for the write method!" geom_placeholder = 'SDE.ST_Geometry(:{}, {})'\ .format(field, self.srid) placeholders.append(geom_placeholder) @@ -1011,6 +1020,7 @@ def write(self, rows, srid=None, table_srid=None, stmt_fields_joined = ', '.join(stmt_fields) prepare_stmt = "INSERT INTO {} ({}) VALUES ({})".format(self._name_with_schema, \ stmt_fields_joined, placeholders_joined) + print(f'prepare_stmt: {prepare_stmt}') self.db.cursor.prepare(prepare_stmt) db_types_filtered = {x.upper(): db_types.get(x.upper()) for x in stmt_fields if x != self.objectid_field} @@ -1095,13 +1105,14 @@ def count(self): ################################################################################ class OracleSdeQuery(SpatialQuery): - def __init__(self, db, table, fields=None, return_geom=True, to_srid=None, + def __init__(self, db, table, fields=None, return_geom=True, to_srid=None, insert_srid=None, where=None, limit=None, timestamp=False, geom_with_srid=False, sql=None): self.db = db self.table = table self.fields = fields self.return_geom = return_geom self.to_srid = to_srid + self.insert_srid = insert_srid self.where = where self.limit = limit self.timestamp = timestamp