forked from scylladb/scylla-cluster-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cql_test.py
49 lines (42 loc) · 1.53 KB
/
cql_test.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
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright (c) 2016 ScyllaDB
import time
from sdcm.tester import ClusterTester
class CQLExampleTest(ClusterTester):
"""
Example test of how to establish CQL connections and run commands on them.
"""
def test_cql_example(self):
"""
Create a table, run a few sql statements
"""
node = self.db_cluster.nodes[0]
with self.cql_connection_patient(node) as session:
self.create_keyspace(keyspace_name='ks', replication_factor=1)
# pylint: disable=no-member
session.execute("""
CREATE TABLE test1 (
k int,
c1 int,
c2 int,
v1 int,
v2 int,
PRIMARY KEY (k, c1, c2)
);
""")
time.sleep(1)
session.execute("INSERT INTO test1 (k, c1, c2, v1, v2) "
"VALUES (1, 2, 3, 4, 5)")
res = session.execute("SELECT v1, v2 from test1")
self.log.debug(res)