forked from RedisGears/rgsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-cql.py
38 lines (30 loc) · 1.04 KB
/
example-cql.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from WriteBehind import RGWriteBehind
from WriteBehind.Connectors import CqlConnector, CqlConnection
'''
Create CQL connection object
'''
connection = CqlConnection('cassandra', 'cassandra', 'cassandra', 'test')
'''
Create CQL person connector
persons - CQL table to put the data
person_id - primary key
'''
personsConnector = CqlConnector(connection, 'persons', 'person_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 CQL cars connector
cars - CQL table to put the data
car_id - primary key
'''
carConnector = CqlConnector(connection, 'cars', 'car_id')
carsMappings = {
'id':'id',
'color':'color'
}
RGWriteBehind(GB, keysPrefix='car', mappings=carsMappings, connector=carsConnector, name='CarsWriteBehind', version='99.99.99')