diff --git a/followthemoney/mapping/sql.py b/followthemoney/mapping/sql.py index d94d8b9c2..a8d31bb99 100644 --- a/followthemoney/mapping/sql.py +++ b/followthemoney/mapping/sql.py @@ -55,10 +55,7 @@ def __init__(self, query: "QueryMapping", data: Dict[str, Any]) -> None: if database is None: raise InvalidMapping("No database in SQL mapping!") self.database_uri = cast(str, os.path.expandvars(database)) - kwargs = {} - if self.database_uri.lower().startswith("postgres"): - kwargs["server_side_cursors"] = True - self.engine = create_engine(self.database_uri, poolclass=NullPool, **kwargs) # type: ignore + self.engine = create_engine(self.database_uri, poolclass=NullPool) # type: ignore self.meta = MetaData() tables = keys_values(data, "table", "tables") @@ -104,7 +101,7 @@ def records(self) -> Generator[Record, None, None]: q = self.compose_query() log.info("Query: %s", q) with self.engine.connect() as conn: - rp = conn.execute(q) + rp = conn.execution_options(stream_results=True).execute(q) while True: rows = rp.fetchmany(size=DATA_PAGE) if not len(rows):