Are prepared statements supported with Azure Cosmos Cassandra API with Python?
It appears not - when I execute
stmt = session.prepare("SELECT provider FROM providers WHERE country_code=?")
I get the following exception:
Traceback (most recent call last):
File "cosmos-cql.py", line 42, in <module>
select_provider_stmt = session.prepare("SELECT provider FROM providers WHERE country_code=?")
File "cassandra\cluster.py", line 3072, in cassandra.cluster.Session.prepare
File "cassandra\cluster.py", line 3069, in cassandra.cluster.Session.prepare
File "cassandra\cluster.py", line 4901, in cassandra.cluster.ResponseFuture.result
File "cassandra\connection.py", line 1229, in cassandra.connection.Connection.process_msg
File "cassandra\protocol.py", line 1196, in cassandra.protocol._ProtocolHandler.decode_message
File "cassandra\protocol.py", line 744, in cassandra.protocol.ResultMessage.recv_body
File "cassandra\protocol.py", line 734, in cassandra.protocol.ResultMessage.recv
File "cassandra\protocol.py", line 775, in cassandra.protocol.ResultMessage.recv_results_prepared
File "cassandra\protocol.py", line 819, in cassandra.protocol.ResultMessage.recv_prepared_metadata
File "cassandra\protocol.py", line 1321, in cassandra.protocol.read_short
File "C:\Users\Ian\.conda\envs\enerlytics\lib\site-packages\cassandra\marshal.py", line 22, in <lambda>
unpack = lambda s: packer.unpack(s)[0]
struct.error: unpack requires a buffer of 2 bytes
I'd normally expect to resolve this in a few minutes by googling, but I can find absolutely nothing about prepared statements and Cosmos Cassandra API. It's as if either the problem doesn't exist (I'm making some really silly mistake) or no one else has even thought to try it.
I am using version 3.25.1 of Datastax's Cassandra driver.
Prepared statements are supported. However, there is a Python driver specific issue with prepared statements in versions higher than 3.20.2 when used with Cosmos DB API for Cassandra. If you downgrade to cassandra-driver==3.20.2, the prepared statement will work.