-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Snowflake example Snowflake example * Gears execution for WB with snowflake RedisGears Write-Behind recipe for snowflake database
- Loading branch information
1 parent
65e0787
commit f9985ae
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Running the recipe | ||
You can use [this utility](https://github.com/RedisGears/RedisGears/blob/master/recipes/gears.py) to send a RedisGears Write-Behind or Write-Through recipe for execution. For example, run this repository's [example.py recipe](https://github.com/rgsync/examples/snowflake/example.py) and install its dependencies with the following command: | ||
|
||
```bash | ||
python gears.py --host <host> --port <port> --password <password> examples/snowflake/example.py REQUIREMENTS rgsync snowflake-sqlalchemy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from rgsync import RGWriteBehind, RGWriteThrough | ||
from rgsync.Connectors import SnowflakeSqlConnector, SnowflakeSqlConnection | ||
|
||
''' | ||
Create Snowflake connection object | ||
The connection object will be translated to snowflake://<user>:<password>@<account>/<db> | ||
''' | ||
connection = SnowflakeSqlConnection('<user>', '<password>', '<account>', '<db>') | ||
|
||
''' | ||
Create Snowflake person1 connector | ||
persons - Snowflake table to put the data | ||
id - primary key | ||
''' | ||
personsConnector = SnowflakeSqlConnector(connection, 'person1', 'id') | ||
|
||
personsMappings = { | ||
'first_name':'first', | ||
'last_name':'last', | ||
'age':'age' | ||
} | ||
|
||
RGWriteBehind(GB, keysPrefix='person', mappings=personsMappings, connector=personsConnector, name='PersonsWriteBehind', version='99.99.99') | ||
|
||
RGWriteThrough(GB, keysPrefix='__', mappings=personsMappings, connector=personsConnector, name='PersonsWriteThrough', version='99.99.99') | ||
|
||
''' | ||
Create Snowflake car connector | ||
car - Snowflake table to put the data | ||
license - primary key | ||
''' | ||
carsConnector = SnowflakeSqlConnector(connection, 'car', 'license') | ||
|
||
carsMappings = { | ||
'license':'license', | ||
'color':'color' | ||
} | ||
|
||
RGWriteBehind(GB, keysPrefix='car', mappings=carsMappings, connector=carsConnector, name='CarsWriteBehind', version='99.99.99') |