pycassa.util – Utilities

A combination of utilities used internally by pycassa and utilities available for use by others working with pycassa.

pycassa.util.convert_time_to_uuid(time_arg, lowest_val=True, randomize=False)

Converts a datetime or timestamp to a type 1 uuid.UUID.

This is to assist with getting a time slice of columns or creating columns when column names are TimeUUIDType. Note that this is done automatically in most cases if name packing and value packing are enabled.

Also, be careful not to rely on this when specifying a discrete set of columns to fetch, as the non-timestamp portions of the UUID will be generated randomly. This problem does not matter with slice arguments, however, as the non-timestamp portions can be set to their lowest or highest possible values.

  • datetime (datetime or timestamp) – The time to use for the timestamp portion of the UUID. Expected inputs to this would either be a datetime object or a timestamp with the same precision produced by time.time(). That is, sub-second precision should be below the decimal place.
  • lowest_val (bool) – Whether the UUID produced should be the lowest possible value UUID with the same timestamp as datetime or the highest possible value.
  • randomize (bool) – Whether the clock and node bits of the UUID should be randomly generated. The lowest_val argument will be ignored if this is true.
Return type:


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.


Converts a version 1 uuid.UUID to a timestamp with the same precision as time.time() returns. This is useful for examining the results of queries returning a v1 UUID.

Parameters:uuid_arg – a version 1 UUID
Return type:timestamp
class pycassa.util.OrderedDict(*args, **kwds)

A dictionary which maintains the insertion order of keys.

A dictionary which maintains the insertion order of keys.

Previous topic

pycassa.types – Data Type Descriptions

Next topic

pycassa.logging.pycassa_logger – Pycassa Logging

This Page