wuttjamaican.db.util

Database Utilities

class wuttjamaican.db.util.UUID(*args, **kwargs)[source]

Platform-independent UUID type.

Uses PostgreSQL’s UUID type, otherwise uses CHAR(32), storing as stringified hex values.

This type definition is based on example from the SQLAlchemy documentation.

cache_ok = True
impl

alias of CHAR

wuttjamaican.db.util.make_topo_sortkey(model)[source]

Returns a function suitable for use as a key kwarg to a standard Python sorting call. This key function will expect a single class mapper and return a sequence number associated with that model. The sequence is determined by SQLAlchemy’s topological table sorting.

Parameters:

model – Usually the app model, but can be any module containing model classes.

wuttjamaican.db.util.uuid_column(*args, **kwargs)[source]

Returns a UUID column for use as a table’s primary key.

wuttjamaican.db.util.uuid_fk_column(target_column, *args, **kwargs)[source]

Returns a UUID column for use as a foreign key to another table.

Parameters:

target_column – Name of the table column on the remote side, e.g. 'user.uuid'.