MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / PrepareMessage

Class PrepareMessage

cassandra/protocol.py:889–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

887
888
889class PrepareMessage(_MessageType):
890 opcode = 0x09
891 name = 'PREPARE'
892
893 def __init__(self, query, keyspace=None):
894 self.query = query
895 self.keyspace = keyspace
896
897 def send_body(self, f, protocol_version):
898 write_longstring(f, self.query)
899
900 flags = 0x00
901
902 if self.keyspace is not None:
903 if ProtocolVersion.uses_keyspace_flag(protocol_version):
904 flags |= _PREPARED_WITH_KEYSPACE_FLAG
905 else:
906 raise UnsupportedOperation(
907 "Keyspaces may only be set on queries with protocol version "
908 "5 or DSE_V2 or higher. Consider setting Cluster.protocol_version.")
909
910 if ProtocolVersion.uses_prepare_flags(protocol_version):
911 write_uint(f, flags)
912 else:
913 # checks above should prevent this, but just to be safe...
914 if flags:
915 raise UnsupportedOperation(
916 "Attempted to set flags with value {flags:0=#8x} on"
917 "protocol version {pv}, which doesn't support flags"
918 "in prepared statements."
919 "Consider setting Cluster.protocol_version to 5 or DSE_V2."
920 "".format(flags=flags, pv=protocol_version))
921
922 if ProtocolVersion.uses_keyspace_flag(protocol_version):
923 if self.keyspace:
924 write_string(f, self.keyspace)
925
926
927class BatchMessage(_MessageType):

Callers 8

test_prepare_messageMethod · 0.90
test_prepare_flagMethod · 0.90
_send_chunksMethod · 0.90
prepareMethod · 0.90
prepare_on_all_hostsMethod · 0.90
_set_resultMethod · 0.90

Calls

no outgoing calls