Skip to content

Commit cf1b2ff

Browse files
SNOW-582911 added parameter files (#288)
1 parent 5fa4d7f commit cf1b2ff

29 files changed

+350
-156
lines changed

.github/ISSUE_TEMPLATE/BUG_REPORT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Please answer these questions before submitting your issue. Thanks!
3333
import logging
3434
import os
3535
36-
for logger_name in ['snowflake.sqlalchemy', 'snowflake.connector']:
36+
for logger_name in ['snowflake.sqlalchemy', 'snowflake.connector']:
3737
logger = logging.getLogger(logger_name)
3838
logger.setLevel(logging.DEBUG)
3939
ch = logging.StreamHandler()

.github/workflows/build_test.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
pull_request:
10+
branches:
11+
- main
12+
- prep-**
13+
workflow_dispatch:
14+
inputs:
15+
logLevel:
16+
17+
default: warning
18+
description: "Log level"
19+
required: true
20+
tags:
21+
description: "Test scenario tags"
22+
jobs:
23+
lint:
24+
name: Check linting
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Set up Python
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: '3.7'
32+
- name: Display Python version
33+
run: python -c "import sys; import os; print(\"\n\".join(os.environ[\"PATH\"].split(os.pathsep))); print(sys.version); print(sys.executable);"
34+
- name: Upgrade setuptools, pip and wheel
35+
run: python -m pip install -U setuptools pip wheel
36+
- name: Install tox
37+
run: python -m pip install tox
38+
- name: Set PY
39+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
40+
- uses: actions/cache@v1
41+
with:
42+
path: ~/.cache/pre-commit
43+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
44+
- name: Run fix_lint
45+
run: python -m tox -e fix_lint
46+
47+
test:
48+
name: Test ${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
49+
needs: lint
50+
runs-on: ${{ matrix.os.image_name }}
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
os:
55+
- image_name: ubuntu-latest
56+
download_name: manylinux_x86_64
57+
- image_name: macos-latest
58+
download_name: macosx_x86_64
59+
- image_name: windows-2019
60+
download_name: win_amd64
61+
python-version: ["3.7"]
62+
cloud-provider: [aws, azure, gcp]
63+
steps:
64+
- uses: actions/checkout@v2
65+
- name: Set up Python
66+
uses: actions/setup-python@v2
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
- name: Display Python version
70+
run: python -c "import sys; print(sys.version)"
71+
- name: Setup parameters file
72+
shell: bash
73+
env:
74+
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
75+
run: |
76+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \
77+
.github/workflows/parameters/parameters_${{ matrix.cloud-provider }}.py.gpg > test/parameters.py
78+
- name: Upgrade setuptools, pip and wheel
79+
run: python -m pip install -U setuptools pip wheel
80+
- name: Install tox
81+
run: python -m pip install --pre tox
82+
- name: Run tests
83+
run: python -m tox -e "py${PYTHON_VERSION/\./}" --skip-missing-interpreters false
84+
env:
85+
PYTHON_VERSION: ${{ matrix.python-version }}
86+
PYTEST_ADDOPTS: -vvv --color=yes --tb=short
87+
TOX_PARALLEL_NO_SPINNER: 1
88+
- name: Combine coverages
89+
run: python -m tox -e coverage --skip-missing-interpreters false
90+
shell: bash
91+
- uses: actions/upload-artifact@v2
92+
with:
93+
name: coverage_${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
94+
path: |
95+
.tox/.coverage
96+
.tox/coverage.xml
97+
98+
combine-coverage:
99+
if: ${{ success() || failure() }}
100+
name: Combine coverage
101+
needs: test
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v2
105+
- uses: actions/download-artifact@v2
106+
with:
107+
path: artifacts
108+
- name: Set up Python
109+
uses: actions/setup-python@v2
110+
with:
111+
python-version: '3.7'
112+
- name: Display Python version
113+
run: python -c "import sys; print(sys.version)"
114+
- name: Upgrade setuptools and pip
115+
run: python -m pip install -U setuptools pip wheel
116+
- name: Install tox
117+
run: python -m pip install tox
118+
- name: Collect all coverages to one dir
119+
run: |
120+
python -c '
121+
from pathlib import Path
122+
import shutil
123+
src_dir = Path("artifacts")
124+
dst_dir = Path(".") / ".tox"
125+
dst_dir.mkdir()
126+
for src_file in src_dir.glob("*/.coverage"):
127+
dst_file = dst_dir / ".coverage.{}".format(src_file.parent.name[9:])
128+
print("{} copy to {}".format(src_file, dst_file))
129+
shutil.copy(str(src_file), str(dst_file))'
130+
- name: Combine coverages
131+
run: python -m tox -e coverage
132+
- name: Publish html coverage
133+
uses: actions/upload-artifact@v2
134+
with:
135+
name: overall_cov_html
136+
path: .tox/htmlcov
137+
- name: Publish xml coverage
138+
uses: actions/upload-artifact@v2
139+
with:
140+
name: overall_cov_xml
141+
path: .tox/coverage.xml
142+
- uses: codecov/codecov-action@v1
143+
with:
144+
file: .tox/coverage.xml
290 Bytes
Binary file not shown.

.github/workflows/parameters/parameters_azure.py.gpg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
� y�g��c�T���fFy4�y�V
2+
ߋ����lXa�RyH���/�X����苬��;�'�R�'��Ό�pgXק[_n�Q���}Ǿ�� :�C��9"�d��r%wI�eM��P4��³�f�;>�T��)ScF�Y>)�D��0����r�]�+G��]O�fs+��_�#K��@�Bh�$°���mBr�]-锞�K�Ov|��w��B���~+s��g>c���ɚ�":G�Q�����ٶ㊢ʄ��{L_�[�+2�ʮ�| ]����)�R�\g'��}�1�w�a��5�� �Nχ�A_:f

.github/workflows/parameters/parameters_gcp.py.gpg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
� Q�ݴ�A%���g(v'����I� ��B�s2qڎ�1�&�n��pqr����\��g��ɫ�5�'���J3��*ڔ�Q�,7�S����r�;�:=�� ��#;B�(����u�]cƭ�㽺(EL�����'����� /ک��S�
2+
]0I���b�ez?�HQ� �4
3+
b�\�+]Ň��3���Kz}h�T�)Y�>��H{�8$���&2)$����.��W?MeZL�T�vVc\TU�q���ٸD��*+���e��_�f`�g�^�Cq���,��J�z�ཚ2
4+
�5��{�'��u�6 �

.pre-commit-config.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
exclude: '^(.*egg.info.*|.*/parameters.py).*$'
22
repos:
33
- repo: https://github.com/asottile/seed-isort-config
4-
rev: v1.9.1
4+
rev: v2.2.0
55
hooks:
66
- id: seed-isort-config
7-
# This work around is necessary until we break the monorepo apart
8-
entry: bash -c "cd Python/snowflake/sqlalchemy && seed-isort-config"
97
- repo: https://github.com/pre-commit/mirrors-isort
10-
rev: v4.3.21
8+
rev: v5.10.1
119
hooks:
1210
- id: isort
1311
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -16,12 +14,11 @@ repos:
1614
- id: trailing-whitespace
1715
- id: end-of-file-fixer
1816
- id: check-yaml
17+
exclude: .github/repo_meta.yaml
1918
- id: debug-statements
2019
- id: flake8
21-
entry: bash -c "cd Python/snowflake/sqlalchemy && flake8"
2220
additional_dependencies: ["flake8-bugbear == 19.3.0"]
2321
- repo: https://github.com/asottile/pyupgrade
24-
rev: v1.19.0
22+
rev: v2.32.1
2523
hooks:
2624
- id: pyupgrade
27-
entry: bash -c "cd Python/snowflake/sqlalchemy && pyupgrade"

DESCRIPTION.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This package includes the Snowflake SQLAlchemy, which supports Snowsql dialects for SQLAlchemy
1+
This package includes the Snowflake SQLAlchemy, which supports Snowsql dialects for SQLAlchemy
22
http://www.sqlalchemy.org/
33

44
Snowflake Documentation is available at:
@@ -16,11 +16,11 @@ Release Notes
1616
- Add support for geography type
1717
- Fixed a bug where foreign key's referred schema was set incorrectly
1818
- Disabled new SQLAlchemy option for statement caching until support gets added
19-
19+
2020
- v1.3.3(December 19,2021)
2121

2222
- Fixed an issue where quote arguments were stripped from identifiers.
23-
23+
2424
- v1.3.2 (September 14,2021)
2525

2626
- Fixed a breaking change introduced in SQLAlchemy 1.4 that changed the behavior of returns_unicode_strings.
@@ -38,13 +38,13 @@ Release Notes
3838
- Fixed an issue where inspector would not properly switch to table wide column retrieving when schema wide column retrieving was taking too long to respond.
3939

4040
- v1.2.3 (March 30, 2020)
41-
41+
4242
- Update tox.ini
4343
- Add external stage to COPY INTO custom command.
4444
- Bumped pandas to newest versions
4545

4646
- v1.2.2 (March 9, 2020)
47-
47+
4848
- Allow get_table_comment to fetch view comments too
4949

5050
- v1.2.1 (February 18,2020)
@@ -77,7 +77,7 @@ Release Notes
7777
- Fix SQLAlchemy not working with global url
7878

7979
- v1.1.15 (September 30, 2019)
80-
80+
8181
- Incorrect SQL generated for INSERT with CTE
8282
- Type Synonyms not exported to top-level module #109
8383

@@ -107,14 +107,14 @@ Release Notes
107107

108108
- v1.1.9 (February 11, 2019)
109109

110-
- Fix an issue in v1.1.8
110+
- Fix an issue in v1.1.8
111111

112112
- v1.1.8 (February 8, 2019)
113113

114114
- Fixed a dependency
115115

116116
- v1.1.7 (February 8, 2019)
117-
117+
118118
- Added Upsert in sql-alchemy
119119
- CopyIntoS3 command in SQLAlchemy
120120

README.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Snowflake SQLAlchemy
99

1010
.. image:: http://img.shields.io/:license-Apache%202-brightgreen.svg
1111
:target: http://www.apache.org/licenses/LICENSE-2.0.txt
12-
12+
1313
Snowflake SQLAlchemy runs on the top of the Snowflake Connector for Python as a `dialect <http://docs.sqlalchemy.org/en/latest/dialects/>`_ to bridge a Snowflake database and SQLAlchemy applications.
1414

1515
Prerequisites
@@ -64,7 +64,7 @@ Verifying Your Installation
6464
connection.close()
6565
engine.dispose()
6666
67-
#. Replace :code:`<your_user_login_name>`, :code:`<your_password>`, and :code:`<your_account_name>` with the appropriate values for your Snowflake account and user. For more details, see `Connection Parameters`_ (in
67+
#. Replace :code:`<your_user_login_name>`, :code:`<your_password>`, and :code:`<your_account_name>` with the appropriate values for your Snowflake account and user. For more details, see `Connection Parameters`_ (in
6868
this topic).
6969

7070
#. Execute the sample code. For example, if you created a file named :code:`validate.py`:
@@ -89,9 +89,9 @@ Snowflake SQLAlchemy uses the following syntax for the connection string used to
8989

9090
.. code-block:: python
9191
92-
'snowflake://<user_login_name>:<password>@<account_name>'
92+
'snowflake://<user_login_name>:<password>@<account_name>'
9393
94-
Where:
94+
Where:
9595

9696
- :code:`<user_login_name>` is the login name for your Snowflake user.
9797
- :code:`<password>` is the password for your Snowflake user.
@@ -113,12 +113,12 @@ You can optionally specify the initial database and schema for the Snowflake ses
113113
The following example calls the :code:`create_engine` method with the user name :code:`testuser1`, password :code:`0123456`, account name :code:`abc123`, database :code:`testdb`, schema :code:`public`, warehouse :code:`testwh`, and role :code:`myrole`:
114114

115115
.. code-block:: python
116-
116+
117117
from sqlalchemy import create_engine
118118
engine = create_engine(
119119
'snowflake://testuser1:0123456@abc123/testdb/public?warehouse=testwh&role=myrole'
120120
)
121-
121+
122122
Other parameters, such as :code:`timezone`, can also be specified as a URI parameter or in :code:`connect_args` parameters. For example:
123123

124124
.. code-block:: python
@@ -128,7 +128,7 @@ Other parameters, such as :code:`timezone`, can also be specified as a URI param
128128
'snowflake://testuser1:0123456@abc123/testdb/public?warehouse=testwh&role=myrole',
129129
connect_args={
130130
'timezone': 'America/Los_Angeles',
131-
}
131+
}
132132
)
133133
134134
For convenience, you can use the :code:`snowflake.sqlalchemy.URL` method to construct the connection string and connect to the database. The following example constructs the same connection string from the previous example:
@@ -157,7 +157,7 @@ Use the supported environment variables, :code:`HTTPS_PROXY`, :code:`HTTP_PROXY`
157157
Opening and Closing Connection
158158
-------------------------------------------------------------------------------
159159

160-
Open a connection by executing :code:`engine.connect()`; avoid using :code:`engine.execute()`. Make certain to close the connection by executing :code:`connection.close()` before
160+
Open a connection by executing :code:`engine.connect()`; avoid using :code:`engine.execute()`. Make certain to close the connection by executing :code:`connection.close()` before
161161
:code:`engine.dispose()`; otherwise, the Python Garbage collector removes the resources required to communicate with Snowflake, preventing the Python connector from closing the session properly.
162162

163163
.. code-block:: python
@@ -183,7 +183,7 @@ Auto-increment Behavior
183183
Auto-incrementing a value requires the :code:`Sequence` object. Include the :code:`Sequence` object in the primary key column to automatically increment the value as each new record is inserted. For example:
184184

185185
.. code-block:: python
186-
186+
187187
t = Table('mytable', metadata,
188188
Column('id', Integer, Sequence('id_seq'), primary_key=True),
189189
Column(...), ...
@@ -220,9 +220,9 @@ The following example shows the round trip of :code:`numpy.datetime64` data:
220220
role='myrole',
221221
numpy=True,
222222
))
223-
223+
224224
specific_date = np.datetime64('2016-03-04T12:03:05.123456789Z')
225-
225+
226226
connection = engine.connect()
227227
connection.execute(
228228
"CREATE OR REPLACE TABLE ts_tbl(c1 TIMESTAMP_NTZ)")
@@ -238,7 +238,7 @@ The following :code:`NumPy` data types are supported:
238238
- numpy.float64
239239
- numpy.datatime64
240240

241-
Cache Column Metadata
241+
Cache Column Metadata
242242
-------------------------------------------------------------------------------
243243

244244
SQLAlchemy provides `the runtime inspection API <http://docs.sqlalchemy.org/en/latest/core/inspection.html>`_ to get the runtime information about the various objects. One of the common use case is get all tables and their column metadata in a schema in order to construct a schema catalog. For example, `alembic <http://alembic.zzzcomputing.com/>`_ on top of SQLAlchemy manages database schema migrations. A pseudo code flow is as follows:
@@ -255,8 +255,8 @@ SQLAlchemy provides `the runtime inspection API <http://docs.sqlalchemy.org/en/l
255255
256256
In this flow, a potential problem is it may take quite a while as queries run on each table. The results are cached but getting column metadata is expensive.
257257

258-
To mitigate the problem, Snowflake SQLAlchemy takes a flag :code:`cache_column_metadata=True` such that all of column metadata for all tables are cached when :code:`get_table_names` is called and the rest of :code:`get_columns`, :code:`get_primary_keys` and :code:`get_foreign_keys` can take advantage of the cache.
259-
258+
To mitigate the problem, Snowflake SQLAlchemy takes a flag :code:`cache_column_metadata=True` such that all of column metadata for all tables are cached when :code:`get_table_names` is called and the rest of :code:`get_columns`, :code:`get_primary_keys` and :code:`get_foreign_keys` can take advantage of the cache.
259+
260260
.. code-block:: python
261261
262262
engine = create_engine(URL(

0 commit comments

Comments
 (0)