Python sqlalchemy_utils.UUIDType() Examples

The following are 2 code examples of sqlalchemy_utils.UUIDType(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy_utils , or try the search function .
Example #1
Source File: sqlalchemy_base.py    From gnocchi with Apache License 2.0 5 votes vote down vote up
def id(cls):
        tablename_compact = cls.__tablename__
        if tablename_compact.endswith("_history"):
            tablename_compact = tablename_compact[:-6]
        return sqlalchemy.Column(
            sqlalchemy_utils.UUIDType(),
            sqlalchemy.ForeignKey(
                'resource.id',
                ondelete="CASCADE",
                name="fk_%s_id_resource_id" % tablename_compact,
                # NOTE(sileht): We use to ensure that postgresql
                # does not use AccessExclusiveLock on destination table
                use_alter=True),
            primary_key=True
        ) 
Example #2
Source File: test_process.py    From eventsourcing with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def define_projection_record_class(self):
        class ProjectionRecord(Base):
            __tablename__ = "projections"

            # Projection ID.
            projection_id = Column(UUIDType(), primary_key=True)

            # State of the projection (serialized dict, possibly encrypted).
            state = Column(Text())

        self.projection_record_class = ProjectionRecord