Skip to main content

snowflake-python-sdk

snowflake sdk for python

This package has been built to help developers build applications using snowflake quickly. below are some examples on how to work with this package

create a snowflake connection

You can create the connection using either a private key or a password. The connection details will need to be upated in the conf.ini file

sample code

Connecting to snowflake:

The below piece of code conects to snowflake and returnd the connection, statuscode and statusmessage:

from utilities.sf_operations import snowflakeconnection

connection = snowflakeconnection(profilename ='snowflake_host')
sfconnectionresults = connection.get_snowflake_connection()

sfconnection = sfconnectionresults.get('connection')
statuscode = sfconnectionresults.get('statuscode')
statusmessage = sfconnectionresults.get('statusmessage')

print(sfconnection,statuscode,statusmessage)

Execute a query in snowflake:

The below piece of code executes a query in snowflake

from utilities.sf_operations import snowflakeconnection
connection = snowflakeconnection(profilename ='snowflake_host')
sfconnectionresults = connection.get_snowflake_connection()

sfconnection = sfconnectionresults.get('connection')
statuscode = sfconnectionresults.get('statuscode')
statusmessage = sfconnectionresults.get('statusmessage')

querystring = "select * from sales;"
queryresult = connection.execute_snowquery(sfconnection,querystring)

queryid = queryresult.get('queryid') #This is the query id in SF
executionresult = queryresult.get('result')
statuscode = queryresult.get('statuscode')
statusmessage = queryresult.get('statusmessage')

print (queryid,statuscode,statusmessage)
for results in executionresult:
    print(results)

sfconnection.close()

Execute a query in snowflake in asynchrouos mode:

This uses the same function but with asyncflag as true

from utilities.sf_operations import snowflakeconnection
connection = snowflakeconnection(profilename ='snowflake_host')
sfconnectionresults = connection.get_snowflake_connection()

sfconnection = sfconnectionresults.get('connection')
statuscode = sfconnectionresults.get('statuscode')
statusmessage = sfconnectionresults.get('statusmessage')

#print(sfconnection,statuscode,statusmessage)

querystring = "select * from ADMCOE_SALES;"
queryresult = connection.execute_snowquery(sfconnection,querystring,asyncflag=True)

queryid = queryresult.get('queryid')
executionresult = queryresult.get('result')
statuscode = queryresult.get('statuscode')
statusmessage = queryresult.get('statusmessage')

Execute a snowflake script in snowflake:

This feature can be used to execute a script file with one or more snowflake queries

from utilities.sf_operations import snowflakeconnection
connection = snowflakeconnection(profilename ='snowflake_host')
sfconnectionresults = connection.get_snowflake_connection()

sfconnection = sfconnectionresults.get('connection')
statuscode = sfconnectionresults.get('statuscode')
statusmessage = sfconnectionresults.get('statusmessage')

#print(sfconnection,statuscode,statusmessage)

filename = "D://script.sql"
queryresult = connection.execute_stream(sfconnection,filename)

executionresult = queryresult.get('result')
statuscode = queryresult.get('statuscode')
statusmessage = queryresult.get('statusmessage')

for cursor in executionresult:
    for ret in cursor:
        print(ret)

print (executionresult,statuscode,statusmessage)

sfconnection.close()

Below features are currently in development progress

  1. Put file to a stage after splitting into multiple files
  2. Compress files before putting them to stage
  3. Archive files after putting them to stage

Metadata

Release files for snowflake-python-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowflake-python-sdk 1.0.0
File Size Uploaded Provenance Actions
snowflake-python-sdk-1.0.0.tar.gz 6.0 kB Without provenance Details for snowflake-python-sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for snowflake-python-sdk 1.0.0
File Interpreter ABI Platform Actions
snowflake_python_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for snowflake_python_sdk-1.0.0-py3-none-any.whl

Total release size: 19.8 kB

Release files / snowflake-python-sdk-1.0.0.tar.gz

Download URL snowflake-python-sdk-1.0.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9167bd0089e35102d52c805c27341af4febd65951dc6c951a0ef6a637f2809da
BLAKE2b-256 checksum
How to use checksums
4e626c78917b0069b361df5997ef3ce5563a0d142deaf07d322147453da19c56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

Release files / snowflake_python_sdk-1.0.0-py3-none-any.whl

Download URL snowflake_python_sdk-1.0.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e735287f02a06270a937e8e81e6ca5c1313d2f14c7ee6d94fe3042817e2244a1
BLAKE2b-256 checksum
How to use checksums
e73e78d44bf0c901f25bd2f7c7f97d22d8420f36dbe107d71820b7f833f822d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

Security for snowflake-python-sdk 1.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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page