This package has been built to help developers build applications using snowflake quickly
Project description
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
- Put file to a stage after splitting into multiple files
- Compress files before putting them to stage
- Archive files after putting them to stage
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file snowflake-python-sdk-1.0.0.tar.gz
.
File metadata
- Download URL: snowflake-python-sdk-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9167bd0089e35102d52c805c27341af4febd65951dc6c951a0ef6a637f2809da |
|
MD5 | d7415034c45a89eb8a12f2b111f7d0c1 |
|
BLAKE2b-256 | 4e626c78917b0069b361df5997ef3ce5563a0d142deaf07d322147453da19c56 |
File details
Details for the file snowflake_python_sdk-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: snowflake_python_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e735287f02a06270a937e8e81e6ca5c1313d2f14c7ee6d94fe3042817e2244a1 |
|
MD5 | c0877e329482ba293f948147f87a6369 |
|
BLAKE2b-256 | e73e78d44bf0c901f25bd2f7c7f97d22d8420f36dbe107d71820b7f833f822d6 |