Ich versuche, Parameter an die SQL -Abfrage zu übergeben, mit der von der Funktion von_Postgis gelesen werden soll, um einen Geopandas -Datenrahmen aus einer Post -GIS -Datenbank zu erhalten. < /p>
from sqlalchemy import create_engine
from sqlalchemy import text
import geopandas as gpd
db_connection_url = "postgresql://user:pwd@host:port/db_name"
engine = create_engine(db_connection_url)
queryVMSint = text('''SELECT vmsint."Code",
vmsint."Date",
extract('YEAR' from "Date") as year,
extract('MONTH' from "Date") as month,
vmsint."Latitude",
vmsint."Longitude",
vmsint.geom,
vmsint."Speed",
vmsint."Course",
vmsint."TrackCode",
vmsint."Effort",
vmsint."Id",
vmsint."Fishing"
FROM vms.vmsint
JOIN vessel ON vessel."Id" = vmsint."VesselId"
JOIN port ON port."Code" = vessel."BasePortCode"
WHERE vmsint."Effort" = true AND port."AutonomousCommunity" = :a AND vessel."GearMainCode" = :b
and extract('YEAR' from "Date") = :c''').bindparams(a=autonomousCommunity, b=fishingGear, c=y)
vmsintf = gpd.GeoDataFrame.from_postgis(queryVMSint, con=engine.connect().connection, geom_col='geom')
< /code>
Dieser Code arbeitete für mich, aber bei der Aktualisierung von Pandas auf 2.2.3 entsteht der folgende Fehler: < /p>
Query must be a string unless using sqlalchemy.
< /code>
Weiß jemand, ob es in .BindParams mit den neuen Versionen von Pandas ein Problem gibt?>
Lesen Sie Geopandas DataFrame mit GPD.From_Postgis -Parametern an sqlalchemy Abfrage ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post