# sme-btutils 0.0.8


sme-btutils is a library to make connections and query Big table data to by passing basic parameters as below:
```
  - column_family_meta
  - column_family_metrics
  - gcp_credentials
  - project_id
  - instance
  - table
```

# Optional parameters
```
  -slack_channel - For receiving notification alerts
  -slack_token
  -file_name - In order to have caller filename mentioned in the alert
```

## Installation

sme-btutils requires python 3.6 + to run.

Installing the sme-btutils package

```
pip install sme-btutils
```

### Example usage:(All parameters are named parameters)
```
from sme_btutils import GcpUtils

gcp_instance = GcpUtils(column_family_meta="column_family_meta",
                        column_family_metrics="column_family_metrics",
                        gcp_credentials="gcp_credentials",
                        project_id="project_id",
                        instance="instance",
                        table="table_name",
                        slack_channel=slack_channel_id,
                        slack_token="slack_token",
                        filename="file_name"
```

```
Prepare columns and rows: 
(columns list and rows need to be respective to each other)

gcp_instance.write_to_big_table(_row_key="row_key",
                                column_name=[list_of_column_names],
                                row_data=[list_of_row_data])


# Batch flusher to start dumping data into big table
gcp_instance.write_row_to_big_table()
```

## If slack parameters are passed, sample alert sent
```
Google Client exception:Could not automatically determine credentials.
Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information,
please see https://cloud.google.com/docs/authentication/getting-started
```

### 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-btutils currently uses following dependencies to function

| DEPENDENCY | VERSION |
| ------ | ------ |
|cachetools|4.1.1|
|certifi|2020.6.20|
|chardet|3.0.4|
|google-api-core|1.16.0|
|google-auth|1.11.3|
|google-cloud|0.34.0|
|google-cloud-bigtable|1.2.1|
|google-cloud-core|1.3.0|
|googleapis-common-protos|1.51.0|
|grpc-google-iam-v1|0.12.3|
|grpcio|1.30.0|
|idna|2.9|
|protobuf|3.12.2|
|pyasn1|0.4.8|
|pyasn1-modules|0.2.8|
|pytz|2020.1|
|requests|2.23.0|
|rsa|4.0|
|six|1.15.0|
|urllib3|1.25.9|
|python-json-logger|0.1.11|
|sme-logger|0.4.0|
|slackclient|2.7.2|
