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_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
ifmapping
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 forIN
value lists.
-
cql_encode_unicode
()[source]¶ Converts
unicode
objects to UTF-8 encoded strings with quote escaping.
-
cql_encode_datetime
()[source]¶ Converts a
datetime.datetime
object to a (string) integer timestamp with millisecond precision.
-
cql_encode_map_collection
()[source]¶ Converts a dict into a string of the form
{key1: val1, key2: val2, ...}
. This is suitable formap
type columns.
-
cql_encode_list_collection
()[source]¶ Converts a sequence to a string of the form
[item1, item2, ...]
. This is suitable forlist
type columns.
-
cql_encode_set_collection
()[source]¶ Converts a sequence to a string of the form
{item1, item2, ...}
. This is suitable forset
type columns.
-
cql_encode_tuple
()¶ Converts a sequence to a string of the form
(item1, item2, ...)
. This is suitable fortuple
type columns.
-