# sme-snowflake 0.0.5


sme-snowflake is a library  to make connections and query snowflake data to by passing basic parameters as below:

```
  - username
  - password
  - account
  - warehouse
  - database
  - schema
```

# Optional parameters
```
  -slack_channel - For receiving notification alerts
  -slack_token
  -file_name - In order to have caller filename mentioned in the alert
```
### Installation

sme-snowflake requires python 3.6 + to run.

Installing the sme-snowflake package

```sh
pip install sme-snowflake
```



### Example usage: (All parameters are named parameters)
```

from sme_snowflake import SnowflakeUtils

snow_flake_instance = SnowflakeUtils(user=user_name,
                                     password=password,
                                     account=account_name,
                                     warehouse=warehouse_name,
                                     database=database_name,
                                     schema=schema_name,
                                     slack_channel=slack_channel_id,
                                     slack_token=token,
                                     filename=caller_file_name)
```
```
Run Query:

snow_flake_instance.run_query(query = your_query_string)
```

### If slack parameters are passed, sample alert sent
```
{
 "ALERT": {
   "Caller": "task",
   "Date": "2020-07-09 01:16:00.344994",
   "Module": "sme-snowflake",
   "Error": "Error creating snowflake connection: Failed to connect to DB: 
   Incorrect username or password was specified."
 }
}
```

### Contributing
```
  - Create your feature branch (git checkout -b feature/fooBar)
  - Increase version in VERSION and README
  - Commit your changes (git commit -am 'Add some fooBar')
  - Push to the branch (git push origin feature/fooBar)
  - Create a new Pull Request into review branch

```

### Dependencies
sme-snowflake currently uses following dependencies to function

| DEPENDENCY | VERSION |
| ------ | ------ |
| asn1crypto | 1.3.0|
|asn1crypto | 1.3.0|
|azure-common | 1.1.25|
|azure-core | 1.6.0|
|azure-storage-blob | 12.3.2|
|boto3 | 1.13.26|
|botocore | 1.16.26|
|certifi | 2020.6.20|
|cffi | 1.14.0|
|chardet | 3.0.4|
|cryptography | 2.9.2|
|docutils | 0.15.2|
|idna | 2.9|
|isodate | 0.6.0|
|jmespath | 0.10.0|
|msrest | 0.6.17|
|oauthlib | 3.1.0|
|oscrypto | 1.2.0|
|pycparser | 2.20|
|pycryptodomex | 3.9.8|
|PyJWT | 1.7.1|
|pyOpenSSL | 19.1.0|
|python-dateutil | 2.8.1|
|python-json-logger | 0.1.11|
|pytz | 2020.1|
|requests | 2.23.0|
|requests-oauthlib | 1.3.0|
|s3transfer | 0.3.3|
|six | 1.15.0|
|sme-logger | 0.4.0|
|snowflake-connector-python | 2.2.8|
|urllib3 | 1.25.9|
|slackclient | 2.7.2|
