GeoAlchemy2 not calling function when executed after upgrading versions

45 views Asked by At

I just upgraded GeoAlchemy2 from version 1.4.x to 2.0.x and am having some issues using the geoalchemy functions now.

Initially when upgrading versions I was getting the following error:

TableClause.insert() takes 1 positional argument but 2 were given

But I saw elsewhere you now pass your values within the connection.execute statement:

# before
conn.execute(table.insert(list_chunks[i]))
# after
conn.execute(table.insert(), list_chunks[i])

And that seems to work where I don't use any geoalchemy fuctions. But my field that uses geoalchemy functions:

values['geometry'] = ST_MakePoint(lon, lat).

Now gets the error:

sqlalchemy.exc.ProgrammingError: (pg8000.dbapi.ProgrammingError) {'S': 'ERROR', 'V': 'ERROR', 'C': 'XX000', 'M': 'parse error - invalid geometry', 'H': '"ST" <- parse error at position 2 within geometry', 'F': 'lwgeom_pg.c', 'L': '186', 'R': 'pg_parser_errhint'

and it looks like the function object is being passed as a parameter, but I assume this is probably not correct:

[parameters: [('2023-12-29 23:12:29', None, 'absent', 'absent', None, <geoalchemy2.functions.ST_MakePoint at 0x23c97e4ed50; ST_MakePoint>
0

There are 0 answers