def prepare(self, query, *args): prepared_query = prepare(query, *args) match = connection._cfamily_re.match(prepared_query) if match: self.column_family = match.group(1) else: match = connection._keyspace_re.match(prepared_query) if match: self.keyspace = match.group(1) return prepared_query
def prepare(self, query, params): prepared_query = prepare(query, params) self._schema_update_needed = False # Snag the keyspace or column family and stash it for later use in # decoding columns. These regexes don't match every query, but the # current column family only needs to be current for SELECTs. match = Cursor._cfamily_re.match(prepared_query) if match: self._query_cf = match.group(1) return prepared_query match = Cursor._keyspace_re.match(prepared_query) if match: self._query_ks = match.group(1) return prepared_query # If this is a CREATE, then refresh the schema for decoding purposes. match = Cursor._ddl_re.match(prepared_query) if match: self._schema_update_needed = True return prepared_query
def test_prepares(self): "test prepared queries against known standards" for (i, test) in enumerate(TESTS): a = prepare(test, *ARGUMENTS[i]) b = STANDARDS[i] assert a == b, "\n%s !=\n%s" % (a, b)