From 8a98e636defeb51fd06ed22267c1fc1b1077cffe Mon Sep 17 00:00:00 2001 From: mikekutzma Date: Thu, 16 Nov 2023 07:46:02 -0500 Subject: [PATCH 1/2] [ADD] Make sqlalchemy_extractor compatible with sqlalchemy>=1.4 Signed-off-by: mikekutzma --- .../databuilder/extractor/sql_alchemy_extractor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/databuilder/databuilder/extractor/sql_alchemy_extractor.py b/databuilder/databuilder/extractor/sql_alchemy_extractor.py index db7e384880..dfdec3935a 100644 --- a/databuilder/databuilder/extractor/sql_alchemy_extractor.py +++ b/databuilder/databuilder/extractor/sql_alchemy_extractor.py @@ -5,7 +5,7 @@ from typing import Any from pyhocon import ConfigFactory, ConfigTree -from sqlalchemy import create_engine +from sqlalchemy import create_engine, text from databuilder import Scoped from databuilder.extractor.base_extractor import Extractor @@ -62,7 +62,11 @@ def _execute_query(self) -> None: Create an iterator to execute sql. """ if not hasattr(self, 'results'): - self.results = self.connection.execute(self.extract_sql) + results = self.connection.execute(text(self.extract_sql)) + # Makes this forward compatible with sqlalchemy >= 1.4 + if hasattr(results, "mappings"): + results = results.mappings() + self.results = results if hasattr(self, 'model_class'): results = [self.model_class(**result) From a382d952c4e00ad37bb840c3ef15d5a503d8d169 Mon Sep 17 00:00:00 2001 From: Mike Kutzma Date: Thu, 16 Nov 2023 10:22:11 -0500 Subject: [PATCH 2/2] Chore: Bump databuilder version to 7.4.6 Signed-off-by: Mike Kutzma --- databuilder/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databuilder/setup.py b/databuilder/setup.py index 6333cf0959..0e1604b5b2 100644 --- a/databuilder/setup.py +++ b/databuilder/setup.py @@ -5,7 +5,7 @@ from setuptools import find_packages, setup -__version__ = '7.4.5' +__version__ = '7.4.6' requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'requirements.txt')