예제 #1
0
 def prepare_query(self, query):
     pquery, paramnames = prepare_query(query)
     prepared = self._connection.wait_for_request(PrepareMessage(query=pquery))
     if isinstance(prepared, ErrorMessage):
         raise cql.Error('Query preparation failed: %s' % prepared.summarymsg())
     if prepared.kind != ResultMessage.KIND_PREPARED:
         raise cql.InternalError('Query preparation did not result in prepared query')
     queryid, colspecs = prepared.results
     kss, cfs, names, ctypes = zip(*colspecs)
     return PreparedQuery(query, queryid, ctypes, paramnames)
예제 #2
0
 def prepare_query(self, query):
     pquery, paramnames = prepare_query(query)
     prepared = self._connection.wait_for_request(PrepareMessage(query=pquery))
     if isinstance(prepared, ErrorMessage):
         raise cql.Error('Query preparation failed: %s' % prepared.summarymsg())
     if prepared.kind != ResultMessage.KIND_PREPARED:
         raise cql.InternalError('Query preparation did not result in prepared query')
     queryid, colspecs = prepared.results
     kss, cfs, names, ctypes = zip(*colspecs)
     return PreparedQuery(query, queryid, ctypes, paramnames)
예제 #3
0
 def prepare_query(self, query):
     if isinstance(query, unicode):
         raise ValueError("CQL query must be bytes, not unicode")
     prepared_q_text, paramnames = prepare_query(query)
     compressed_q, compression = self.compress_query_text(prepared_q_text)
     presult = self._connection.client.prepare_cql_query(compressed_q, compression)
     assert presult.count == len(paramnames)
     if presult.variable_types is None and presult.count > 0:
         raise cql.ProgrammingError("Cassandra did not provide types for bound"
                                    " parameters. Prepared statements are only"
                                    " supported with cql3.")
     return PreparedQuery(query, presult.itemId, presult.variable_types, paramnames)
예제 #4
0
 def prepare_query(self, query):
     if isinstance(query, unicode):
         raise ValueError("CQL query must be bytes, not unicode")
     prepared_q_text, paramnames = prepare_query(query)
     compressed_q, compression = self.compress_query_text(prepared_q_text)
     presult = self._connection.client.prepare_cql_query(
         compressed_q, compression)
     assert presult.count == len(paramnames)
     if presult.variable_types is None and presult.count > 0:
         raise cql.ProgrammingError(
             "Cassandra did not provide types for bound"
             " parameters. Prepared statements are only"
             " supported with cql3.")
     return PreparedQuery(query, presult.itemId, presult.variable_types,
                          paramnames)