sqlalchemy_utils.CompositeType

Here are the examples of the python api sqlalchemy_utils.CompositeType taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

Example 1

Project: sqlalchemy-utils Source File: test_composite.py
Function: account
    @pytest.fixture
    def Account(self, Base):
        class Account(Base):
            __tablename__ = 'account'
            id = sa.Column(sa.Integer, primary_key=True)
            balance = sa.Column(
                CompositeType(
                    'money_type',
                    [
                        sa.Column('currency', sa.String),
                        sa.Column('amount', sa.Integer)
                    ]
                )
            )

        return Account

Example 2

Project: sqlalchemy-utils Source File: test_composite.py
Function: account
    @pytest.fixture
    def Account(self, Base):
        class Account(Base):
            __tablename__ = 'account'
            id = sa.Column(sa.Integer, primary_key=True)
            balance = sa.Column(
                CompositeType(
                    'money_type',
                    [
                        sa.Column('currency', CurrencyType),
                        sa.Column('amount', sa.Integer)
                    ]
                )
            )

        return Account

Example 3

Project: sqlalchemy-utils Source File: test_composite.py
Function: type
    @pytest.fixture
    def type_(self):
        return CompositeType(
            'money_type',
            [
                sa.Column('currency', CurrencyType),
                sa.Column('amount', sa.Integer)
            ]
        )

Example 4

Project: sqlalchemy-utils Source File: test_composite.py
Function: type
    @pytest.fixture
    def type_(self):
        return CompositeType(
            'category',
            [
                sa.Column('scale', NumericRangeType),
                sa.Column('name', sa.String)
            ]
        )

Example 5

Project: sqlalchemy-utils Source File: test_composite.py
Function: account
    @pytest.fixture
    def Account(self, Base):
        pg_composite.registered_composites = {}

        type_ = CompositeType(
            'money_type',
            [
                sa.Column('currency', sa.String),
                sa.Column('amount', sa.Integer)
            ]
        )

        class Account(Base):
            __tablename__ = 'account'
            id = sa.Column(sa.Integer, primary_key=True)
            balance = sa.Column(type_)

        return Account