diff --git a/HISTORY.rst b/HISTORY.rst index 7dc5c79..94aa064 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ======= +v0.15.3 (2021-10-27) + +* Move the import of pyodbc within the function that uses it since it requires additional dependencies. + + v0.15.2 (2021-10-13) * Fix error in FICE enrolled logic by setting enrolled field instead of confirmed. diff --git a/aioradio/file_ingestion.py b/aioradio/file_ingestion.py index e4f5d2a..812428f 100644 --- a/aioradio/file_ingestion.py +++ b/aioradio/file_ingestion.py @@ -2,6 +2,7 @@ # pylint: disable=broad-except # pylint: disable=consider-using-enumerate +# pylint: disable=import-outside-toplevel # pylint: disable=invalid-name # pylint: disable=logging-fstring-interpolation # pylint: disable=too-many-arguments @@ -18,6 +19,7 @@ import logging import os import re +import sys import time import zipfile from asyncio import sleep @@ -37,7 +39,6 @@ from aioradio.aws.secrets import get_secret from aioradio.psycopg2 import establish_psycopg2_connection -from aioradio.pyodbc import establish_pyodbc_connection DIRECTORY = Path(__file__).parent.absolute() LOG = logging.getLogger('file_ingestion') @@ -1042,6 +1043,11 @@ async def child_wrapper(*args, **kwargs) -> Any: if item['db'] in ['pyodbc', 'psycopg2']: creds = {**json.loads(await get_secret(item['secret'], item['region'])), **{'database': item.get('database', '')}} if item['db'] == 'pyodbc': + # Add import here because it requires extra dependencies many systems + # don't have out of the box so only import when explicitly being used + if 'pyodbc' not in sys.modules: + from aioradio.pyodbc import \ + establish_pyodbc_connection conns[item['name']] = await establish_pyodbc_connection(**creds, autocommit=False) elif item['db'] == 'psycopg2': conns[item['name']] = await establish_psycopg2_connection(**creds) diff --git a/setup.py b/setup.py index 40bc54b..f8a382d 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = fileobj.read() setup(name='aioradio', - version='0.15.2', + version='0.15.3', description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more', long_description=long_description, long_description_content_type="text/markdown",