sqlalchemy.orm.relationship

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

200 Examples 7

Example 1

Project: cassiopeia
Source File: currentgame.py
View license
def _sa_bind_current_game_info():
    global CurrentGameInfo

    @cassiopeia.type.core.common.inheritdocs
    class CurrentGameInfo(CurrentGameInfo, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "CurrentGameInfo"
        bannedChampions = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.BannedChampion", cascade="all, delete-orphan", passive_deletes=True)
        gameId = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        gameLength = sqlalchemy.Column(sqlalchemy.Integer)
        gameMode = sqlalchemy.Column(sqlalchemy.String(30))
        gameQueueConfigId = sqlalchemy.Column(sqlalchemy.Integer)
        gameStartTime = sqlalchemy.Column(sqlalchemy.BigInteger)
        gameType = sqlalchemy.Column(sqlalchemy.String(30))
        mapId = sqlalchemy.Column(sqlalchemy.Integer)
        observers = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.Observer", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        participants = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.CurrentGameParticipant", cascade="all, delete-orphan", passive_deletes=True)
        platformId = sqlalchemy.Column(sqlalchemy.String(30))

Example 2

Project: cassiopeia
Source File: currentgame.py
View license
def _sa_bind_current_game_info():
    global CurrentGameInfo

    @cassiopeia.type.core.common.inheritdocs
    class CurrentGameInfo(CurrentGameInfo, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "CurrentGameInfo"
        bannedChampions = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.BannedChampion", cascade="all, delete-orphan", passive_deletes=True)
        gameId = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        gameLength = sqlalchemy.Column(sqlalchemy.Integer)
        gameMode = sqlalchemy.Column(sqlalchemy.String(30))
        gameQueueConfigId = sqlalchemy.Column(sqlalchemy.Integer)
        gameStartTime = sqlalchemy.Column(sqlalchemy.BigInteger)
        gameType = sqlalchemy.Column(sqlalchemy.String(30))
        mapId = sqlalchemy.Column(sqlalchemy.Integer)
        observers = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.Observer", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        participants = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.CurrentGameParticipant", cascade="all, delete-orphan", passive_deletes=True)
        platformId = sqlalchemy.Column(sqlalchemy.String(30))

Example 3

Project: cassiopeia
Source File: featuredgames.py
View license
def _sa_bind_featured_game_info():
    global FeaturedGameInfo

    @cassiopeia.type.core.common.inheritdocs
    class FeaturedGameInfo(FeaturedGameInfo, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "FeaturedGameInfo"
        bannedChampions = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.BannedChampion", cascade="all, delete-orphan", passive_deletes=True)
        gameId = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        gameLength = sqlalchemy.Column(sqlalchemy.Integer)
        gameMode = sqlalchemy.Column(sqlalchemy.String(30))
        gameQueueConfigId = sqlalchemy.Column(sqlalchemy.Integer)
        gameStartTime = sqlalchemy.Column(sqlalchemy.BigInteger)
        gameType = sqlalchemy.Column(sqlalchemy.String(30))
        mapId = sqlalchemy.Column(sqlalchemy.Integer)
        observers = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Observer", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        participants = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Participant", cascade="all, delete-orphan", passive_deletes=True)
        platformId = sqlalchemy.Column(sqlalchemy.String(30))

Example 4

Project: cassiopeia
Source File: featuredgames.py
View license
def _sa_bind_featured_game_info():
    global FeaturedGameInfo

    @cassiopeia.type.core.common.inheritdocs
    class FeaturedGameInfo(FeaturedGameInfo, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "FeaturedGameInfo"
        bannedChampions = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.BannedChampion", cascade="all, delete-orphan", passive_deletes=True)
        gameId = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        gameLength = sqlalchemy.Column(sqlalchemy.Integer)
        gameMode = sqlalchemy.Column(sqlalchemy.String(30))
        gameQueueConfigId = sqlalchemy.Column(sqlalchemy.Integer)
        gameStartTime = sqlalchemy.Column(sqlalchemy.BigInteger)
        gameType = sqlalchemy.Column(sqlalchemy.String(30))
        mapId = sqlalchemy.Column(sqlalchemy.Integer)
        observers = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Observer", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        participants = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Participant", cascade="all, delete-orphan", passive_deletes=True)
        platformId = sqlalchemy.Column(sqlalchemy.String(30))

Example 5

Project: cassiopeia
Source File: featuredgames.py
View license
def _sa_bind_featured_game_info():
    global FeaturedGameInfo

    @cassiopeia.type.core.common.inheritdocs
    class FeaturedGameInfo(FeaturedGameInfo, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "FeaturedGameInfo"
        bannedChampions = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.BannedChampion", cascade="all, delete-orphan", passive_deletes=True)
        gameId = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        gameLength = sqlalchemy.Column(sqlalchemy.Integer)
        gameMode = sqlalchemy.Column(sqlalchemy.String(30))
        gameQueueConfigId = sqlalchemy.Column(sqlalchemy.Integer)
        gameStartTime = sqlalchemy.Column(sqlalchemy.BigInteger)
        gameType = sqlalchemy.Column(sqlalchemy.String(30))
        mapId = sqlalchemy.Column(sqlalchemy.Integer)
        observers = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Observer", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        participants = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Participant", cascade="all, delete-orphan", passive_deletes=True)
        platformId = sqlalchemy.Column(sqlalchemy.String(30))

Example 6

Project: cassiopeia
Source File: featuredgames.py
View license
def _sa_bind_featured_game_info():
    global FeaturedGameInfo

    @cassiopeia.type.core.common.inheritdocs
    class FeaturedGameInfo(FeaturedGameInfo, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "FeaturedGameInfo"
        bannedChampions = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.BannedChampion", cascade="all, delete-orphan", passive_deletes=True)
        gameId = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        gameLength = sqlalchemy.Column(sqlalchemy.Integer)
        gameMode = sqlalchemy.Column(sqlalchemy.String(30))
        gameQueueConfigId = sqlalchemy.Column(sqlalchemy.Integer)
        gameStartTime = sqlalchemy.Column(sqlalchemy.BigInteger)
        gameType = sqlalchemy.Column(sqlalchemy.String(30))
        mapId = sqlalchemy.Column(sqlalchemy.Integer)
        observers = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Observer", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        participants = sqlalchemy.orm.relationship("cassiopeia.type.dto.featuredgames.Participant", cascade="all, delete-orphan", passive_deletes=True)
        platformId = sqlalchemy.Column(sqlalchemy.String(30))

Example 7

Project: lux
Source File: models.py
View license
    @declared_attr
    def user(cls):
        return relationship(
            'User',
            backref=backref("mailinglists", cascade="all, delete-orphan")
        )

Example 8

Project: lux
Source File: models.py
View license
    @odm.declared_attr
    def organisation(cls):
        return relationship(
            "Organisation",
            backref="applications"
        )

Example 9

Project: lux
Source File: models.py
View license
    @odm.declared_attr
    def application(cls):
        return relationship(
            "AppDomain",
            backref=backref("organisation", uselist=False)
        )

Example 10

Project: iktomi
Source File: mixin.py
View license
    def test_reference(self):
        def TreeMixIn(cls):
            @declared_mixin
            def _TreeMixIn():
                id = Column(Integer, primary_key=True)
                parent_id = Column(ForeignKey(id))
                parent = relationship(cls, remote_side=id)
            return _TreeMixIn
        class A(self.Base, TreeMixIn('A')): pass
        class B(self.Base, TreeMixIn('B')): pass

Example 11

Project: sqlalchemy_mptt
Source File: mixins.py
View license
    @declared_attr
    def parent(self):
        return relationship(
            self,
            order_by=lambda: self.left,
            foreign_keys=[self.parent_id],
            remote_side='{}.{}'.format(self.__name__, self.get_pk_name()),
            backref=backref('children', cascade="all,delete",
                            order_by=lambda: (self.tree_id, self.left)),
        )

Example 12

Project: cruzdb
Source File: sqlsoup.py
View license
    def relate(cls, propname, *args, **kwargs):
        """Produce a relationship between this mapped table and another
        one. 
        
        This makes usage of SQLAlchemy's :func:`sqlalchemy.orm.relationship`
        construct.
        
        """
        class_mapper(cls)._configure_property(propname, relationship(*args, **kwargs))

Example 13

Project: stalker
Source File: test_validate_with_query.py
View license
    @declared_attr
    def b(cls):
        return relationship(
            "B",
            primaryjoin="%s.b_id==B.b_id" % cls.__name__
        )

Example 14

View license
def test_relation(Base):
    class Foo(Base):
        __tablename__ = 'foo'
        id = Column(types.Integer, primary_key=True)
    class Bar(Base):
        __tablename__ = 'bar'
        id = Column(types.Integer, primary_key=True)
        foo_id = Column(types.Integer, ForeignKey(Foo.id))
    Foo.bars = relationship(Bar)
    graph = sasd.create_uml_graph(mappers(Foo, Bar))
    assert sorted(graph.obj_dict['nodes'].keys()) == ['"Bar"', '"Foo"']
    assert '+id : Integer' in graph.obj_dict['nodes']['"Foo"'][0]['attributes']['label']
    assert '+foo_id : Integer' in graph.obj_dict['nodes']['"Bar"'][0]['attributes']['label']
    assert 'edges' in graph.obj_dict
    assert ('"Foo"', '"Bar"') in graph.obj_dict['edges']
    assert graph.obj_dict['edges'][('"Foo"', '"Bar"')][0]['attributes']['headlabel'] == '+bars *'

Example 15

View license
def test_backref(Base):
    class Foo(Base):
        __tablename__ = 'foo'
        id = Column(types.Integer, primary_key=True)
    class Bar(Base):
        __tablename__ = 'bar'
        id = Column(types.Integer, primary_key=True)
        foo_id = Column(types.Integer, ForeignKey(Foo.id))
    Foo.bars = relationship(Bar, backref='foo')
    graph = sasd.create_uml_graph(mappers(Foo, Bar))
    assert sorted(graph.obj_dict['nodes'].keys()) == ['"Bar"', '"Foo"']
    assert '+id : Integer' in graph.obj_dict['nodes']['"Foo"'][0]['attributes']['label']
    assert '+foo_id : Integer' in graph.obj_dict['nodes']['"Bar"'][0]['attributes']['label']
    assert 'edges' in graph.obj_dict
    assert ('"Foo"', '"Bar"') in graph.obj_dict['edges']
    assert ('"Bar"', '"Foo"') in graph.obj_dict['edges']
    assert graph.obj_dict['edges'][('"Foo"', '"Bar"')][0]['attributes']['headlabel'] == '+bars *'
    assert graph.obj_dict['edges'][('"Bar"', '"Foo"')][0]['attributes']['headlabel'] == '+foo 0..1'

Example 16

Project: bedup
Source File: model.py
View license
def FK(cattr, primary_key=False, backref=None, nullable=False, cascade=False):
    # cascade=False will select the sqla default (save-update, merge)
    col, = cattr.property.columns
    if backref is None:
        assert cascade is False
    else:
        backref = backref_(backref, cascade=cascade)

    return (
        Column(
            col.type, ForeignKey(col),
            primary_key=primary_key,
            nullable=nullable),
        relationship(
            parent_entity(cattr), backref=backref))

Example 17

Project: ggrc-core
Source File: customattributable.py
View license
  @declared_attr
  def custom_attribute_definitions(self):
    """Load custom attribute definitions"""
    from ggrc.models.custom_attribute_definition\
        import CustomAttributeDefinition

    def join_function():
      """Object and CAD join function."""
      definition_id = foreign(CustomAttributeDefinition.definition_id)
      definition_type = foreign(CustomAttributeDefinition.definition_type)
      return and_(or_(definition_id == self.id, definition_id.is_(None)),
                  definition_type == self._inflector.table_singular)

    return relationship(
        "CustomAttributeDefinition",
        primaryjoin=join_function,
        backref='{0}_custom_attributable_definition'.format(self.__name__),
        viewonly=True,
    )

Example 18

Project: ggrc-core
Source File: customattributable.py
View license
  @declared_attr
  def _custom_attribute_values(self):
    """Load custom attribute values"""
    from ggrc.models.custom_attribute_value import CustomAttributeValue

    def join_function():
      return and_(
          foreign(CustomAttributeValue.attributable_id) == self.id,
          foreign(CustomAttributeValue.attributable_type) == self.__name__)
    return relationship(
        "CustomAttributeValue",
        primaryjoin=join_function,
        backref='{0}_custom_attributable'.format(self.__name__),
        cascade='all, delete-orphan',
    )

Example 19

Project: timesketch
Source File: acl.py
View license
    @declared_attr
    def user(self):
        """A relationship to a user object.

        Returns:
            A relationship (instance of sqlalchemy.orm.relationship)
        """
        return relationship(u'User')

Example 20

Project: timesketch
Source File: acl.py
View license
    @declared_attr
    def group(self):
        """A relationship to a group object.

        Returns:
            A relationship (instance of sqlalchemy.orm.relationship)
        """
        return relationship(u'Group')

Example 21

Project: timesketch
Source File: annotations.py
View license
    @declared_attr
    def user(self):
        """A relationship to a user object.

        Returns:
            A relationship (instance of sqlalchemy.orm.relationship)
        """
        return relationship(u'User')

Example 22

Project: dms
Source File: master_sm.py
View license
    @classmethod
    def _mapper_properties(class_):
        ServerGroup = sql_types['ServerGroup']
        ServerSM = sql_types['ServerSM']
        return {'replica_sg': relationship(ServerGroup, backref='master_sm'),
                'master_server': relationship(ServerSM, 
                                        backref='master_sm')}

Example 23

Project: dms
Source File: reference.py
View license
    @classmethod
    def _mapper_properties(class_):
        zone_sm_type = sql_types['ZoneSM']
        zone_sm_table = sql_data['tables'][zone_sm_type]
        rr_type = sql_types['ResourceRecord']
        return {
                'zones': relationship(zone_sm_type, passive_deletes=True,
                                lazy='dynamic'),
                            }

Example 24

Project: dms
Source File: resource_record.py
View license
    @classmethod
    def _mapper_properties(class_):
        rr_table = sql_data['tables'][sql_types['ResourceRecord']]
        rr_comment_table = sql_data['tables'][sql_types['RRComment']]
        ref_type = sql_types['Reference']
        ref_table = sql_data['tables'][ref_type]
        return {'rr_comment': relationship(sql_types['RRComment'],
                                    primaryjoin=(rr_table.c.comment_rr_id 
                                            == rr_comment_table.c.get('id')),
                                        uselist=False,
                                        backref="rr"),
                'group_comment': relationship(sql_types['RRComment'],
                                    primaryjoin=(rr_table.c.comment_group_id 
                                            == rr_comment_table.c.get('id')),
                                        backref="rr_group"),
                'reference': relationship(sql_types['Reference'],
                                        viewonly=True),
                }

Example 25

Project: dms
Source File: update_group.py
View license
    @classmethod
    def _mapper_properties(class_):
        zone_sm_type = sql_types['ZoneSM']
        zone_sm_table = sql_data['tables'][zone_sm_type]
        rr_type = sql_types['ResourceRecord']
        rr_table = sql_data['tables'][rr_type]
        return {
                'update_ops': relationship(rr_type, passive_deletes=True,
                                order_by=rr_table.c.get('id'), 
                                backref='update_group'),
                            }

Example 26

View license
    def setUp(self):
        super(TestFetchRelatedResource, self).setUp()

        class Article(self.Base):
            __tablename__ = 'article'
            id = Column(Integer, primary_key=True)
            author_id = Column(Integer, ForeignKey('person.id'))
            author = relationship('Person', backref=backref('articles'))

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)

        self.Article = Article
        self.Person = Person
        self.Base.metadata.create_all()

Example 27

View license
    def setUp(self):
        super(TestDeleting, self).setUp()

        class Article(self.Base):
            __tablename__ = 'article'
            id = Column(Integer, primary_key=True)
            author_id = Column(Integer, ForeignKey('person.id'))
            author = relationship('Person', backref=backref('articles'))

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)

        self.Article = Article
        self.Person = Person
        self.Base.metadata.create_all()
        self.manager.create_api(Person, methods=['PATCH'],
                                allow_delete_from_to_many_relationships=True)
        self.manager.create_api(Article)

Example 28

View license
    def setUp(self):
        super(TestUpdatingToMany, self).setUp()

        class Article(self.Base):
            __tablename__ = 'article'
            id = Column(Integer, primary_key=True)
            author_id = Column(Integer, ForeignKey('person.id'))
            author = relationship('Person', backref=backref('articles'))

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)

        self.Article = Article
        self.Person = Person
        self.Base.metadata.create_all()
        self.manager.create_api(Person, methods=['PATCH'],
                                allow_to_many_replacement=True)
        self.manager.create_api(Article)

Example 29

View license
    def setUp(self):
        super(TestUpdatingToOne, self).setUp()

        class Article(self.Base):
            __tablename__ = 'article'
            id = Column(Integer, primary_key=True)
            author_id = Column(Integer, ForeignKey('person.id'))
            author = relationship('Person', backref=backref('articles'))

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)

        self.Article = Article
        self.Person = Person
        self.Base.metadata.create_all()
        self.manager.create_api(Article, methods=['PATCH'])
        self.manager.create_api(Person)

Example 30

Project: guardrail
Source File: sqlalchemy.py
View license
    def _update_parents(self, agent, target, schema):
        """Create a many-to-many `relationship` between the `agent` and `target`
        schemas, using the created `schema` as the join table.

        Note: Use the `passive_deletes` and `passive_updates` flags only if the
        database backend supports the ON UPDATE and ON DELETE cascades. These
        options are not supported in SQLite, or in MySQL using the MyISAM storage
        engine.
        """
        attr = 'targets_{0}'.format(schema.__tablename__)
        backref = 'agents_{0}'.format(schema.__tablename__)
        relation = sa.orm.relationship(
            target,
            secondary=schema.__table__,
            backref=backref,
            passive_deletes=self.cascade,
            passive_updates=self.cascade,
        )
        setattr(agent, attr, relation)

Example 31

Project: postgresql-audit
Source File: base.py
View license
def assign_actor(base, cls, actor_cls):
    if hasattr(cls, 'actor_id'):
        return
    if actor_cls:
        primary_key = sa.inspect(actor_cls).primary_key[0]

        cls.actor_id = sa.Column('actor_id', primary_key.type)
        cls.actor = orm.relationship(
            actor_cls,
            primaryjoin=cls.actor_id == (
                getattr(
                    actor_cls,
                    primary_key.name
                )
            ),
            foreign_keys=[cls.actor_id]
        )
    else:
        cls.actor_id = sa.Column(sa.Text)

Example 32

Project: postgresql-audit
Source File: base.py
View license
def assign_actor(base, cls, actor_cls):
    if hasattr(cls, 'actor_id'):
        return
    if actor_cls:
        primary_key = sa.inspect(actor_cls).primary_key[0]

        cls.actor_id = sa.Column('actor_id', primary_key.type)
        cls.actor = orm.relationship(
            actor_cls,
            primaryjoin=cls.actor_id == (
                getattr(
                    actor_cls,
                    primary_key.name
                )
            ),
            foreign_keys=[cls.actor_id]
        )
    else:
        cls.actor_id = sa.Column(sa.Text)

Example 33

Project: cassiopeia
Source File: currentgame.py
View license
def _sa_bind_current_game_participant():
    global CurrentGameParticipant

    @cassiopeia.type.core.common.inheritdocs
    class CurrentGameParticipant(CurrentGameParticipant, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "CurrentGameParticipant"
        bot = sqlalchemy.Column(sqlalchemy.Boolean)
        championId = sqlalchemy.Column(sqlalchemy.Integer)
        masteries = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.Mastery", cascade="all, delete-orphan", passive_deletes=True)
        profileIconId = sqlalchemy.Column(sqlalchemy.Integer)
        runes = sqlalchemy.orm.relationship("cassiopeia.type.dto.currentgame.Rune", cascade="all, delete-orphan", passive_deletes=True)
        spell1Id = sqlalchemy.Column(sqlalchemy.Integer)
        spell2Id = sqlalchemy.Column(sqlalchemy.Integer)
        summonerId = sqlalchemy.Column(sqlalchemy.Integer)
        summonerName = sqlalchemy.Column(sqlalchemy.String(30))
        teamId = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        _game_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("CurrentGameInfo.gameId", ondelete="CASCADE"))

Example 34

Project: cassiopeia
Source File: league.py
View license
def _sa_bind_league_entry():
    global LeagueEntry

    @cassiopeia.type.core.common.inheritdocs
    class LeagueEntry(LeagueEntry, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "LeagueEntry"
        division = sqlalchemy.Column(sqlalchemy.String(30))
        isFreshBlood = sqlalchemy.Column(sqlalchemy.Boolean)
        isHotStreak = sqlalchemy.Column(sqlalchemy.Boolean)
        isInactive = sqlalchemy.Column(sqlalchemy.Boolean)
        isVeteran = sqlalchemy.Column(sqlalchemy.Boolean)
        leaguePoints = sqlalchemy.Column(sqlalchemy.Integer)
        losses = sqlalchemy.Column(sqlalchemy.Integer)
        miniSeries = sqlalchemy.orm.relationship("cassiopeia.type.dto.league.MiniSeries", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        playerOrTeamId = sqlalchemy.Column(sqlalchemy.String(50))
        playerOrTeamName = sqlalchemy.Column(sqlalchemy.String(30))
        wins = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        _league_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("League._id", ondelete="CASCADE"))

Example 35

Project: cassiopeia
Source File: league.py
View license
def _sa_bind_league():
    global League

    @cassiopeia.type.core.common.inheritdocs
    class League(League, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "League"
        entries = sqlalchemy.orm.relationship("cassiopeia.type.dto.league.LeagueEntry", cascade="all, delete-orphan", passive_deletes=True)
        name = sqlalchemy.Column(sqlalchemy.String(30))
        participantId = sqlalchemy.Column(sqlalchemy.String(50))
        queue = sqlalchemy.Column(sqlalchemy.String(30))
        tier = sqlalchemy.Column(sqlalchemy.String(30))
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)

Example 36

Project: cassiopeia
Source File: league.py
View license
def _sa_bind_league():
    global League

    @cassiopeia.type.core.common.inheritdocs
    class League(League, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "League"
        entries = sqlalchemy.orm.relationship("cassiopeia.type.dto.league.LeagueEntry", cascade="all, delete-orphan", passive_deletes=True)
        name = sqlalchemy.Column(sqlalchemy.String(30))
        participantId = sqlalchemy.Column(sqlalchemy.String(50))
        queue = sqlalchemy.Column(sqlalchemy.String(30))
        tier = sqlalchemy.Column(sqlalchemy.String(30))
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)

Example 37

Project: cassiopeia
Source File: stats.py
View license
def _sa_bind_player_stats_summary():
    global PlayerStatsSummary

    @cassiopeia.type.core.common.inheritdocs
    class PlayerStatsSummary(PlayerStatsSummary, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "PlayerStatsSummary"
        aggregatedStats = sqlalchemy.orm.relationship("cassiopeia.type.dto.stats.AggregatedStats", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        losses = sqlalchemy.Column(sqlalchemy.Integer)
        modifyDate = sqlalchemy.Column(sqlalchemy.BigInteger)
        playerStatSummaryType = sqlalchemy.Column(sqlalchemy.String(30))
        wins = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)

Example 38

Project: cassiopeia
Source File: stats.py
View license
def _sa_bind_player_stats_summary():
    global PlayerStatsSummary

    @cassiopeia.type.core.common.inheritdocs
    class PlayerStatsSummary(PlayerStatsSummary, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "PlayerStatsSummary"
        aggregatedStats = sqlalchemy.orm.relationship("cassiopeia.type.dto.stats.AggregatedStats", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        losses = sqlalchemy.Column(sqlalchemy.Integer)
        modifyDate = sqlalchemy.Column(sqlalchemy.BigInteger)
        playerStatSummaryType = sqlalchemy.Column(sqlalchemy.String(30))
        wins = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)

Example 39

Project: cassiopeia
Source File: status.py
View license
def _sa_bind_incident():
    global Incident

    @cassiopeia.type.core.common.inheritdocs
    class Incident(Incident, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "Incident"
        active = sqlalchemy.Column(sqlalchemy.Boolean)
        created_at = sqlalchemy.Column(sqlalchemy.String(30))
        id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        updates = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Message", cascade="all, delete-orphan", passive_deletes=True)
        _service_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("Service._id", ondelete="CASCADE"))

Example 40

Project: cassiopeia
Source File: status.py
View license
def _sa_bind_service():
    global Service

    @cassiopeia.type.core.common.inheritdocs
    class Service(Service, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "Service"
        incidents = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Incident", cascade="all, delete-orphan", passive_deletes=True)
        name = sqlalchemy.Column(sqlalchemy.String(30))
        slug = sqlalchemy.Column(sqlalchemy.String(30))
        status = sqlalchemy.Column(sqlalchemy.String(30))
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        _shard_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("ShardStatus._id", ondelete="CASCADE"))

Example 41

Project: cassiopeia
Source File: status.py
View license
def _sa_bind_service():
    global Service

    @cassiopeia.type.core.common.inheritdocs
    class Service(Service, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "Service"
        incidents = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Incident", cascade="all, delete-orphan", passive_deletes=True)
        name = sqlalchemy.Column(sqlalchemy.String(30))
        slug = sqlalchemy.Column(sqlalchemy.String(30))
        status = sqlalchemy.Column(sqlalchemy.String(30))
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        _shard_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("ShardStatus._id", ondelete="CASCADE"))

Example 42

Project: cassiopeia
Source File: status.py
View license
def _sa_bind_shard_status():
    global ShardStatus

    @cassiopeia.type.core.common.inheritdocs
    class ShardStatus(ShardStatus, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "ShardStatus"
        hostname = sqlalchemy.Column(sqlalchemy.String(50))
        locales = sqlalchemy.Column(cassiopeia.type.dto.common.JSONEncoded)
        name = sqlalchemy.Column(sqlalchemy.String(30))
        region_tag = sqlalchemy.Column(sqlalchemy.String(30))
        services = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Service", cascade="all, delete-orphan", passive_deletes=True)
        slug = sqlalchemy.Column(sqlalchemy.String(30))
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)

Example 43

Project: cassiopeia
Source File: summoner.py
View license
def _sa_bind_rune_page():
    global RunePage

    @cassiopeia.type.core.common.inheritdocs
    class RunePage(RunePage, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "RunePage"
        current = sqlalchemy.Column(sqlalchemy.Boolean)
        id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        name = sqlalchemy.Column(sqlalchemy.String(50))
        slots = sqlalchemy.orm.relationship("cassiopeia.type.dto.summoner.RuneSlot", cascade="all, delete-orphan, delete, merge", passive_deletes=True)

Example 44

Project: cassiopeia
Source File: team.py
View license
def _sa_bind_roster():
    global Roster

    @cassiopeia.type.core.common.inheritdocs
    class Roster(Roster, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "Roster"
        memberList = sqlalchemy.orm.relationship("cassiopeia.type.dto.team.TeamMemberInfo", cascade="all, delete-orphan", passive_deletes=True)
        ownerId = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        _team_id = sqlalchemy.Column(sqlalchemy.String(50), sqlalchemy.ForeignKey("Team.fullId", ondelete="CASCADE"))

Example 45

Project: cassiopeia
Source File: stats.py
View license
def _sa_bind_player_stats_summary():
    global PlayerStatsSummary

    @cassiopeia.type.core.common.inheritdocs
    class PlayerStatsSummary(PlayerStatsSummary, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "PlayerStatsSummary"
        aggregatedStats = sqlalchemy.orm.relationship("cassiopeia.type.dto.stats.AggregatedStats", uselist=False, cascade="all, delete-orphan", passive_deletes=True)
        losses = sqlalchemy.Column(sqlalchemy.Integer)
        modifyDate = sqlalchemy.Column(sqlalchemy.BigInteger)
        playerStatSummaryType = sqlalchemy.Column(sqlalchemy.String(30))
        wins = sqlalchemy.Column(sqlalchemy.Integer)
        _id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)

Example 46

Project: cassiopeia
Source File: status.py
View license
def _sa_bind_message():
    global Message

    @cassiopeia.type.core.common.inheritdocs
    class Message(Message, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "Message"
        author = sqlalchemy.Column(sqlalchemy.String(30))
        content = sqlalchemy.Column(sqlalchemy.Text)
        created_at = sqlalchemy.Column(sqlalchemy.String(30))
        id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        severity = sqlalchemy.Column(sqlalchemy.String(30))
        translations = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Translation", cascade="all, delete-orphan", passive_deletes=True)
        updated_at = sqlalchemy.Column(sqlalchemy.String(30))
        _incident_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("Incident.id", ondelete="CASCADE"))

Example 47

Project: cassiopeia
Source File: status.py
View license
def _sa_bind_incident():
    global Incident

    @cassiopeia.type.core.common.inheritdocs
    class Incident(Incident, cassiopeia.type.dto.common.BaseDB):
        __tablename__ = "Incident"
        active = sqlalchemy.Column(sqlalchemy.Boolean)
        created_at = sqlalchemy.Column(sqlalchemy.String(30))
        id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
        updates = sqlalchemy.orm.relationship("cassiopeia.type.dto.status.Message", cascade="all, delete-orphan", passive_deletes=True)
        _service_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey("Service._id", ondelete="CASCADE"))

Example 48

Project: python-social-auth
Source File: models.py
View license
def init_social(app, session):
    UID_LENGTH = app.config.get(setting_name('UID_LENGTH'), 255)
    User = module_member(app.config[setting_name('USER_MODEL')])
    _AppSession._set_session(session)
    UserSocialAuth.__table_args__ = (UniqueConstraint('provider', 'uid'),)
    UserSocialAuth.uid = Column(String(UID_LENGTH))
    UserSocialAuth.user_id = Column(Integer, ForeignKey(User.id),
                                    nullable=False, index=True)
    UserSocialAuth.user = relationship(User, backref=backref('social_auth',
                                                             lazy='dynamic'))

Example 49

Project: palladium
Source File: persistence.py
View license
    def DBModelClass(self, Base):
        class DBModel(Base):
            __tablename__ = self._table_postfix('models')
            version = Column(Integer, primary_key=True)
            metadata_ = Column(
                'metadata', String(length=10 ** 6), nullable=False)
            chunks = relationship(
                'DBModelChunk',
                order_by="DBModelChunk.id",
                )
        return DBModel

Example 50

Project: sqlalchemy-imageattach
Source File: entity.py
View license
def image_attachment(*args, **kwargs):
    """The helper function, decorates raw
    :func:`~sqlalchemy.orm.relationship()` function, sepcialized for
    relationships between :class:`Image` subtypes.

    It takes the same parameters as :func:`~sqlalchemy.orm.relationship()`.

    If ``uselist`` is :const:`True`, it becomes possible to attach multiple
    image sets.  In order to attach multiple image sets, image entity types
    must have extra discriminating primary key columns to group each image set.

    If ``uselist`` is :const:`False` (which is default), it becomes
    possible to attach only a single image.

    :param \*args: the same arguments as
                   :func:`~sqlalchemy.orm.relationship()`
    :param \*\*kwargs: the same keyword arguments as
                       :func:`~sqlalchemy.orm.relationship()`
    :returns: the relationship property
    :rtype: :class:`sqlalchemy.orm.properties.RelationshipProperty`

    .. versionadded:: 1.0.0
       The ``uselist`` parameter.

    .. todo::

       It currently doesn't support population (eager loading) on
       :func:`image_attachment()` relationships yet.

       We seem to need to work something on attribute instrumental
       implementation.

    """
    if kwargs.get('uselist', False):
        kwargs.setdefault('query_class', MultipleImageSet)
    else:
        kwargs.setdefault('query_class', SingleImageSet)
    kwargs['uselist'] = True
    kwargs.setdefault('lazy', 'dynamic')
    kwargs.setdefault('cascade', 'all, delete-orphan')
    return relationship(*args, **kwargs)