I've just created two Cassandra clusters through Docker. The docker exec -it name nodetool status
command tells that clusters created everything is ok:
Then I'll try to INSERT data to table from the Python driver.
Here is my code:
from cassandra.cluster import Cluster
from faker import Faker
import time
fake = Faker()
num = 0
cluster = Cluster(['172.17.0.2', '172.17.0.3'], port=9042)
session = cluster.connect()
session.execute('USE keys')
print("Start create data")
start = time.time()
for i in range(10000):
time.sleep(0.001)
num+=1
session.execute(
"""
INSERT INTO tt (id, title) VALUES (%(id)s, %(title)s)
""",
{'id': num, 'title': fake.address()}
)
end = time.time()
print("Total time: ", end - start)
And finally when I try to execute the code I gave the following error in the terminal: