cassandra.encoder - Encoders for non-prepared StatementsΒΆ

class cassandra.encoder.Encoder[source]ΒΆ

A container for mapping python types to CQL string literals when working with non-prepared statements. The type mapping can be directly customized by users.

mapping = NoneΒΆ

A map of python types to encoder functions.

cql_encode_none()[source]ΒΆ

Converts None to the string β€˜NULL’.

cql_encode_object()[source]ΒΆ

Default encoder for all objects that do not have a specific encoder function registered. This function simply calls str() on the object.

cql_encode_all_types()[source]ΒΆ

Converts any type into a CQL string, defaulting to cql_encode_object if mapping does not contain an entry for the type.

cql_encode_sequence()[source]ΒΆ

Converts a sequence to a string of the form (item1, item2, ...). This is suitable for IN value lists.

cql_encode_str()[source]ΒΆ

Escapes quotes in str objects.

cql_encode_unicode()[source]ΒΆ

Converts unicode objects to UTF-8 encoded strings with quote escaping.

cql_encode_bytes()[source]ΒΆ

Converts strings, buffers, and bytearrays into CQL blob literals.

cql_encode_datetime()[source]ΒΆ

Converts a datetime.datetime object to a (string) integer timestamp with millisecond precision.

cql_encode_date()[source]ΒΆ

Converts a datetime.date object to a string with format YYYY-MM-DD.

cql_encode_map_collection()[source]ΒΆ

Converts a dict into a string of the form {key1: val1, key2: val2, ...}. This is suitable for map type columns.

cql_encode_list_collection()[source]ΒΆ

Converts a sequence to a string of the form [item1, item2, ...]. This is suitable for list type columns.

cql_encode_set_collection()[source]ΒΆ

Converts a sequence to a string of the form {item1, item2, ...}. This is suitable for set type columns.

cql_encode_tuple()ΒΆ

Converts a sequence to a string of the form (item1, item2, ...). This is suitable for tuple type columns.