Skip to content

Commit

Permalink
new insert_srid arg, and assert self.srid is not None for writes
Browse files Browse the repository at this point in the history
  • Loading branch information
floptical committed Aug 16, 2024
1 parent 7eb7f06 commit d00544c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion geopetl/oracle_sde.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ def write(self, rows, srid=None, table_srid=None,
# TODO some tables just don't have a srid -- this should probably go
# somewhere else, or needs more logic
#######################################################################
# table_srid = table_srid or self.srid
table_srid = table_srid or self.srid
# if table_srid is None:
# raise ValueError('Table does not define an SRID. Please provide '
# 'a value for `table_srid` or register the '
Expand Down Expand Up @@ -960,6 +960,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)
Expand Down Expand Up @@ -1011,6 +1016,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}
Expand Down

0 comments on commit d00544c

Please sign in to comment.