sfu
Snowflake URI utility library that supports extraction of Snowflake configuration data and method parameters from Snowflake resource URIs.
Purpose
When applications that employ the Snowflake Python SDK must work with resources that are spread across multiple accounts, it can be useful to tie Snowflake configuration information (both credentials and resource data) directly tot associated Snowflake resources (e.g., by including the configuration data within URIs). This library provides a class that extracts Snowflake configuration data and method parameters from a URI, offering a succint syntax for passing (directly into Snowflake methods) configuration data and/or resource names that are included within URIs.
Package Installation and Usage
The package is available on PyPI:
python -m pip install sfu
The sfu class can be imported with:
from sfu import sfu
The class provides methods for extracting configuration data (credentials and non-credentials) from URIs, as in the examples below:
>>> from sfu import sfu
>>> import snowflake.connector
# Create a connector client given a URI (for a table in some snowflake database) that
# includes credentials (a username 'ABC', a password 'XYZ', and an associated account
# 'UVW').
# Make sure the account contains the region and platform, e.g., xxx.us-east-1.aws.
>>> s = sfu("snow://ABC:XYZ:UVW@DATABASE")
>>> conn = connector.connect(**s.credentials())
# It can also be useful to bind a connection to some database and some data processing
# warehouse, so you don't need to execute cursor commands later. The following will
# return a connector client that is configured against DATABASE, using WH for data
# processing.
>>> uri = "snow://ABC:XYZ:UVW@DATABASE/TABLE@warehouse=WH"
>>> s = sfu(uri)
>>> c = connector.connect(**s.for_connection())
>>> cs = c.cursor()
>>> cs.execute(f"SELECT col1,col2 FROM {s.for_table()}")
# Note that this is equivalent to the following:
>>> s = sfu(uri)
>>> c = connector.connect(**s.credentials())
>>> cs = c.cursor()
>>> cs.execute(f"USE DATABASE {s.for_db()}")
>>> cs.execute(f"USE WAREHOUSE {s.for_warehouse()}")
>>> cs.execute(f"SELECT col1,col2 FROM {s.for_table()}")
Developer Notes
Pipenv is used for dependency management of the main library, minus Read the Docs which does not support Pipenv. You can install all dependencies with:
pipenv install --dev
To release a new version of the library, run:
pipenv run python -m pip install --upgrade build twine pipenv run python -m build pipenv run python -m twine upload dist/*
Documentation
The documentation can be generated automatically from the source files using Sphinx:
python -m pip install -e . cd docs python -m pip install -r requirements.txt sphinx-apidoc -f -E --templatedir=_templates -o _source .. && make html
Testing and Conventions
All unit tests are executed and their coverage is measured when using pytest:
pipenv run python -m pytest --cov=sfu --cov-report term-missing
Style conventions are enforced using Pylint:
pipenv run python -m flake8 src/sfu
Contributions
In order to contribute to the source code, open an issue or submit a pull request on the GitHub page for this library.
Versioning
The version number format for this library and the changes to the library associated with version number increments conform with Semantic Versioning 2.0.0.
MIT License
Copyright (c) 2021 Nth Party, Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for sfu 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sfu-2.0.0.tar.gz | 6.4 kB | Without provenance | Details for sfu-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sfu-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for sfu-2.0.0-py3-none-any.whl |
Total release size: 12.8 kB
Release files / sfu-2.0.0.tar.gz
| Download URL | sfu-2.0.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b4f83ea93f58decdbdbc275129e068247f9f84bbdc7dbefb3e293f0b737cfd8
|
|
BLAKE2b-256 checksum How to use checksums |
a48479db15dd509d192a274e3d31703ab055cac6562e2d1804b4736d6d84be3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.6
|
Release files / sfu-2.0.0-py3-none-any.whl
| Download URL | sfu-2.0.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39d894b1dcf5f707ec2e1c74e37c333e7701223c0d4b6a555fbff9d5f1533eef
|
|
BLAKE2b-256 checksum How to use checksums |
437a9ea21eb5d87da825f23ebc74495ec3cc892292c716a6d1738c8f600ec884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.6
|
Security for sfu 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.