I have a postgres-postgis dB with a geometry:point field: if I insert the 
values directly 
INSERT INTO points(coordinates) VALUES (ST_GeomFromText('POINT(10.809003 
54.097834)',4326));

no issue, but if I use this sequence (Python)
*->import data in a dataframe: data contains lat and long columns;*
*-> trasform the lon,lat column in a shapely.geometry.point;*
*->create a geodataframe (gdf)*
*->connect to dB with psycopg2 and sqlalchemy*

gdf.to_sql('<mytable>, conn,if_exists='append
',index=False,schema=<myschema>)


I got this error:

--------------------------------------------------------------------------ProgrammingError
                          Traceback (most recent call 
last)/opt/conda/lib/python3.7/site-packages/sqlalchemy/engine/base.py in 
_execute_context(self, dialect, constructor, statement, parameters, *args)   
1223                     self.dialect.do_executemany(-> 1224                    
     cursor, statement, parameters, context   1225                     )
/opt/conda/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py
 in do_executemany(self, cursor, statement, parameters, context)    751         
else:--> 752             cursor.executemany(statement, parameters)    753 
ProgrammingError: can't adapt type 'Point'


Any hints?


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/0a501873-7f27-45d1-93ec-c08aa0922a30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to