我正试图找到一种方法来记录从python代码在Cassandra上完成的所有查询.特别是日志记录,因为他们使用a执行 BatchStatement
我可以使用任何钩子或回调来记录这个吗?
我尝试使用 Python 驱动程序中的 BATCH 将 150.000 个生成的数据插入到 Cassandra 中。大约需要30 秒。我应该如何优化它并更快地插入数据?这是我的代码:
from cassandra.cluster import Cluster
from faker import Faker
import time
fake = Faker()
cluster = Cluster(['127.0.0.1'], port=9042)
session = cluster.connect()
session.default_timeout = 150
num = 0
def create_data():
global num
BATCH_SIZE = 1500
BATCH_STMT = 'BEGIN BATCH'
for i in range(BATCH_SIZE):
BATCH_STMT += f" INSERT INTO tt(id, title) VALUES ('{num}', '{fake.name()}')";
num += 1
BATCH_STMT += ' APPLY BATCH;'
prep_batch = session.prepare(BATCH_STMT)
return prep_batch
tt = []
session.execute('USE …Run Code Online (Sandbox Code Playgroud) 我正在发送来回Python和Cassandra的数据.我float在我的python程序中使用了内置 类型和我的Cassandra表的数据类型.如果我955.99从python 发送一个数字到Cassandra,它会显示在数据库中955.989999.当我在python中发送一个查询以返回我刚刚发送的值时,现在就是955.989990234375.
我理解python中精确丢失的问题,我只是想知道Cassandra中是否存在可以防止此问题的任何内置机制.
python floating-point precision cassandra cassandra-python-driver