-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathTestCass.py
33 lines (24 loc) · 827 Bytes
/
TestCass.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
from cassandra.cluster import Cluster
from cassandra.cqlengine import connection
from cassandra.cqlengine.management import sync_table
from flask import Flask
from models.user import Person
from views.api import api
KEYSPACE = "cassandra_final_try"
def create_app():
app = Flask(__name__)
app.debug = True
app.register_blueprint(api)
cluster = Cluster()
session = cluster.connect()
session.execute(
"""
CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
""" % KEYSPACE)
session = cluster.connect(keyspace=KEYSPACE)
return app
app = create_app()
if __name__ == '__main__':
connection.setup(['127.0.0.1'], "cqlengine", protocol_version=3)
sync_table(Person)
app.run(host="0.0.0.0", port=8081)