### Navigation

- index
- modules |
- next |
- previous |
- pycassa 1.11.1 documentation »
- API Documentation »

# `pycassa.types` – Data Type Descriptions

Data type definitions that are used when converting data to and from the binary format that the data will be stored in.

In addition to the default classes included here, you may also define custom types by creating a new class that extends `CassandraType`. For example, IntString, which stores an arbitrary integer as a string, may be defined as follows:

    >>> class IntString(pycassa.types.CassandraType):
    ...
    ...    @staticmethod
    ...    def pack(intval):
    ...        return str(intval)
    ...
    ...    @staticmethod
    ...    def unpack(strval):
    ...        return int(strval)

class `pycassa.types.``CassandraType`(reversed=False, default=None)

  A data type that Cassandra is aware of and knows how to validate and sort. All of the other classes in this module are subclasses of this class.

  If reversed is true and this is used as a column comparator, the columns will be sorted in reverse order.

  The default parameter only applies to use of this with ColumnFamilyMap, where default is used if a row does not contain a column corresponding to this item.

class `pycassa.types.``BytesType`

  Stores data as a byte array

class `pycassa.types.``AsciiType`

  Stores data as ASCII text

class `pycassa.types.``UTF8Type`

  Stores data as UTF8 encoded text

class `pycassa.types.``LongType`

  Stores data as an 8 byte integer

class `pycassa.types.``IntegerType`

  Stores data as a variable-length integer. This is a more compact format for storing small integers than `LongType`, and the limits on the size of the integer are much higher.

  Changed in version 1.2.0: Prior to 1.2.0, this was always stored as a 4 byte integer.

class `pycassa.types.``DoubleType`

  Stores data as an 8 byte double

class `pycassa.types.``FloatType`

  Stores data as a 4 byte float

class `pycassa.types.``DecimalType`

  Stores an unlimited precision decimal number. decimal.Decimal objects are used by pycassa to represent these objects.

class `pycassa.types.``DateType`

  An 8 byte timestamp. This will be returned as a `datetime.datetime` instance by pycassa. Either `datetime` instances or timestamps will be accepted.

  Changed in version 1.7.0: Prior to 1.7.0, datetime objects were expected to be in local time. In 1.7.0 and beyond, naive datetimes are assumed to be in UTC and tz-aware objects will be automatically converted to UTC for storage in Cassandra.

class `pycassa.types.``UUIDType`

  Stores data as a type 1 or type 4 UUID

class `pycassa.types.``TimeUUIDType`

  Stores data as a version 1 UUID

class `pycassa.types.``LexicalUUIDType`

  Stores data as a non-version 1 UUID

class `pycassa.types.``OldPycassaDateType`

  This class can only read and write the DateType format used by pycassa versions 1.2.0 to 1.5.0.

  This formats store the number of microseconds since the unix epoch, rather than the number of milliseconds, which is what cassandra-cli and other clients supporting DateType use.

  Changed in version 1.7.0: Prior to 1.7.0, datetime objects were expected to be in local time. In 1.7.0 and beyond, naive datetimes are assumed to be in UTC and tz-aware objects will be automatically converted to UTC for storage in Cassandra.

class `pycassa.types.``IntermediateDateType`

  This class is capable of reading either the DateType format by pycassa versions 1.2.0 to 1.5.0 or the correct format used in pycassa 1.5.1+. It will only write the new, correct format.

  This type is a good choice when you are using DateType as the validator for non-indexed column values and you are in the process of converting from thee old format to the new format.

  It almost certainly should not be used for row keys, column names (if you care about the sorting), or column values that have a secondary index on them.

  Changed in version 1.7.0: Prior to 1.7.0, datetime objects were expected to be in local time. In 1.7.0 and beyond, naive datetimes are assumed to be in UTC and tz-aware objects will be automatically converted to UTC for storage in Cassandra.

class `pycassa.types.``CompositeType`(*components)

  A type composed of one or more components, each of which have their own type. When sorted, items are primarily sorted by their first component, secondarily by their second component, and so on.

  Each of *components should be an instance of a subclass of `CassandraType`.

  See also

  Composite Types

class `pycassa.types.``DynamicCompositeType`(*aliases)

  A type composed of one or more components, each of which have their own type. When sorted, items are primarily sorted by their first component, secondarily by their second component, and so on.

  Unlike CompositeType, DynamicCompositeType columns need not all be of the same structure. Each column can be composed of different component types.

  Components are specified using a 2-tuple made up of a comparator type and value. Aliases for comparator types can optionally be specified with a dictionary during instantiation.

### Navigation

- index
- modules |
- next |
- previous |
- pycassa 1.11.1 documentation »
- API Documentation »