I need help with this error, AttributeError: 'Transaction' object has no attribute 'run_callable'
from sqlalchemy import create_engine
import pandas as pd
def insert(df):
calidades_df = df.copy()
calidades_df.insert(loc=0, column='proceso', value=p['proceso'])
calidades_df.insert(
loc=len(calidades_df.columns),
column='baja',
value=False)
engine = create_engine(
"postgres://usr:pass#@localhost:5432/database"
)
with engine.begin() as conn:
calidades_df.to_postgis(
'calidades',
conn,
schema='ndvi',
if_exists='append',
index=False
)
The error occurs only when using geopandas dataframe with the to_postgis() function. With pandas dataframes using the to_sql() function works fine. Thanks in advance
I stumbled accross the same problem and it seems the to_postgis()
method is kind of broken. So what I did is implementing https://gis.stackexchange.com/a/239231/36712 which uses the to_sql()
from pandas. You just have to make your geometry into WKT
and defining a dtype for the geometry column.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.