Skip to content

Commit

Permalink
Add attr_before parameter in pyodbc.connect
Browse files Browse the repository at this point in the history
  • Loading branch information
tim.reichard committed Jun 1, 2021
1 parent f85c042 commit fef5c34
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ History
=======


v0.13.7 (2021-06-02)
-----------------------

* Add attr_before parameter in pyodbc.connect.


v0.13.5 (2021-04-27)
-----------------------

Expand Down
11 changes: 5 additions & 6 deletions aioradio/file_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,12 @@ async def unzip_file(filepath: str, directory: str) -> List[str]:
List[str]: List of filenames
"""

zipped = zipfile.ZipFile(filepath)
filenames = []
with zipfile.ZipFile(filepath) as zipped:

# exclude __MACOSX directory that could be added when creating zip on macs
filenames = [i for i in zipped.namelist() if '__MACOSX' not in i]

zipped.extractall(directory)
zipped.close()
# exclude __MACOSX directory that could be added when creating zip on macs
filenames = [i for i in zipped.namelist() if '__MACOSX' not in i]
zipped.extractall(directory)

return filenames

Expand Down
3 changes: 2 additions & 1 deletion aioradio/pyodbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pyodbc

OPERATING_SYSTEM = platform.system()
SQL_ATTR_CONNECTION_TIMEOUT = 113

# driver location varies based on OS. add to this list if necessary...
UNIXODBC_DRIVER_PATHS = [
Expand Down Expand Up @@ -92,7 +93,7 @@ async def establish_pyodbc_connection(
if multi_subnet_failover:
conn_string += f';MultiSubnetFailover={multi_subnet_failover}'

return pyodbc.connect(conn_string, autocommit=autocommit)
return pyodbc.connect(conn_string, autocommit=autocommit, attr_before={SQL_ATTR_CONNECTION_TIMEOUT: 3})


async def pyodbc_query_fetchone(conn: pyodbc.Connection, query: str) -> Union[List[Any], None]:
Expand Down
22 changes: 11 additions & 11 deletions aioradio/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
aioboto3==8.3.0
aiobotocore==1.3.0
aiojobs==0.3.0
ddtrace==0.48.0
fakeredis==1.5.0
flask==1.1.2
httpx==0.17.1
ddtrace==0.49.2
fakeredis==1.5.1
flask==2.0.1
httpx==0.18.1
mandrill==1.0.60
moto==1.3.16
orjson==3.5.1
pre-commit==2.12.0
orjson==3.5.3
pre-commit==2.13.0
psycopg2-binary==2.8.6
pylint==2.7.4
pylint==2.8.3
pyodbc==4.0.30
pysmb==1.2.6
pytest==6.2.3
pytest-asyncio==0.14.0
pytest-cov==2.11.1
pysmb==1.2.7
pytest==6.2.4
pytest-asyncio==0.15.1
pytest-cov==2.12.1
python-json-logger==2.0.1
redis==3.5.3
twine==3.4.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = fileobj.read()

setup(name='aioradio',
version='0.13.6',
version='0.13.7',
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",
Expand Down

0 comments on commit fef5c34

Please sign in to comment.