Я пытаюсь передать параметры в SQL -запрос, который будет прочитать с помощью функции From_postgis, чтобы получить Geopandas DataFrame из базы данных PostGIS. < /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>
Этот код работал для меня, но при обновлении Pandas до 2.2.3 возникает следующая ошибка: < /p>
Query must be a string unless using sqlalchemy.
< /code>
Кто -нибудь знает, есть ли проблема в .bindparams с новыми версиями Pandas?
geopandas version = 1.0.1
sqlalchemy version = 1.4.44 < /p>
Подробнее здесь: https://stackoverflow.com/questions/796 ... sqlalchemy
Читать Geopandas DataFrame с GPD.From_postgis Передача параметров SQLALCHEMY Запрос ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Читать Geopandas DataFrame с GPD.From_postgis Передача параметров SQLALCHEMY Запрос
Anonymous » » в форуме Python - 0 Ответы
- 6 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Geopandas: как читать CSV и конвертировать в фрейм данных GeoPandas с многоугольниками?
Anonymous » » в форуме Python - 0 Ответы
- 38 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Geopandas: Как прочитать CSV и преобразовать в Geopandas DataFrame с полигонами?
Anonymous » » в форуме Python - 0 Ответы
- 17 Просмотры
-
Последнее сообщение Anonymous
-