How to use the sqlalchemy.Column function in SQLAlchemy

To help you get started, we’ve selected a few SQLAlchemy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Murali-group / GraphSpace / migration / versions / 5976898cbe4c_update_edges_table_change_tail_node_.py View on Github external
def upgrade():
	# # Replacing tail_node_id with node id in edge table
	op.alter_column('edge', 'tail_node_id', new_column_name='tail_node_name')
	op.add_column('edge', sa.Column('tail_node_id', sa.Integer))
	op.execute('UPDATE edge SET tail_node_id=n.id FROM "node" AS n WHERE n.name = edge.tail_node_name AND n.graph_id = edge.graph_id;')
	# op.drop_column('edge', 'tail_node_name')
	op.alter_column('edge', 'tail_node_id', nullable=False)
github billvsme / videoSpider / models / medium / medium.py View on Github external
summary = Column(String)
    cover = Column(String)
    covers = Column(String)
    thumbnail_covers = Column(String)
    pubdate = Column(String)

    is_detail = Column(Boolean, default=False)

    douban_id = Column(String)
    douban_url = Column(String)
    cover_x = Column(Integer)
    cover_y = Column(Integer)
    is_new = Column(Boolean)
    is_beetle_subject = Column(Boolean)
    douban_rate = Column(String)
    douban_rating = Column(String)
    douban_ratings_count = Column(String)

    bilibili_id = Column(String)

    languages = relationship(
            'Language',
            secondary=medium_language_table,
            backref='media'
    )
    countries = relationship(
            'Country',
            secondary=medium_country_table,
            backref='media'
    )

    type = Column(String(50))
github geoadmin / mf-chsdi3 / chsdi / models / vector / uvek.py View on Github external
__label__ = 'prog'
    id = Column('gid', Integer, primary_key=True)
    prog = Column('prog', Unicode)
    the_geom = Column(Geometry2D)

register('ch.bakom.versorgungsgebiet-ukw', Bakomukw)


class EinschraenkungenDrohnen(Base, Vector):
    __tablename__ = 'einschraenkungen_drohnen'
    __table_args__ = ({'schema': 'bazl', 'autoload': False})
    __template__ = 'templates/htmlpopup/einschraenkungen_drohnen.mako'
    __bodId__ = 'ch.bazl.einschraenkungen-drohnen'
    id = Column('bgdi_id', Integer, primary_key=True)
    name_de = Column('name_de', Unicode)
    name_fr = Column('name_fr', Unicode)
    name_it = Column('name_it', Unicode)
    name_en = Column('name_en', Unicode)
    restr_de = Column('restr_de', Unicode)
    restr_fr = Column('restr_fr', Unicode)
    restr_it = Column('restr_it', Unicode)
    restr_en = Column('restr_en', Unicode)
    bew_st_de = Column('bew_st_de', Unicode)
    bew_st_fr = Column('bew_st_fr', Unicode)
    bew_st_it = Column('bew_st_it', Unicode)
    bew_st_en = Column('bew_st_en', Unicode)
    bew_li_de = Column('bew_li_de', Unicode)
    bew_li_fr = Column('bew_li_fr', Unicode)
    bew_li_it = Column('bew_li_it', Unicode)
    bew_li_en = Column('bew_li_en', Unicode)
    the_geom = Column(Geometry2D)
github steemit / hivemind / hive / db / schema.py View on Github external
sa.Index('hive_posts_cache_ix8', 'category', 'payout', 'depth', postgresql_where=sql_text("is_paidout = '0'")), # API: tag stats
        sa.Index('hive_posts_cache_ix9a', 'depth', 'payout', 'post_id', postgresql_where=sql_text("is_paidout = '0'")), # API: payout
        sa.Index('hive_posts_cache_ix9b', 'category', 'depth', 'payout', 'post_id', postgresql_where=sql_text("is_paidout = '0'")), # API: filtered payout

        mysql_engine='InnoDB',
        mysql_default_charset='utf8mb4'
    )

    sa.Table(
        'hive_state', metadata,
        sa.Column('block_num', sa.Integer, primary_key=True, autoincrement=False),
        sa.Column('db_version', sa.Integer, nullable=False),
        sa.Column('steem_per_mvest', sa.types.DECIMAL(8, 3), nullable=False),
        sa.Column('usd_per_steem', sa.types.DECIMAL(8, 3), nullable=False),
        sa.Column('sbd_per_steem', sa.types.DECIMAL(8, 3), nullable=False),
        sa.Column('dgpo', sa.Text, nullable=False),

        mysql_engine='InnoDB',
        mysql_default_charset='utf8mb4'
    )

    return metadata
github apache / airflow / airflow / migrations / versions / 64de9cddf6c9_add_task_fails_journal_table.py View on Github external
def upgrade():
    op.create_table(
        'task_fail',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('task_id', sa.String(length=250), nullable=False),
        sa.Column('dag_id', sa.String(length=250), nullable=False),
        sa.Column('execution_date', sa.DateTime(), nullable=False),
        sa.Column('start_date', sa.DateTime(), nullable=True),
        sa.Column('end_date', sa.DateTime(), nullable=True),
        sa.Column('duration', sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
    )
github singnet / snet-marketplace-service / dapp_user / alembic / versions / e46dc1dce28b_baseline.py View on Github external
""")
    conn.execute("""
            CREATE TABLE `user_service_feedback` (
              `row_id` int(11) NOT NULL AUTO_INCREMENT,
              `username` varchar(128) NOT NULL,
              `org_id` varchar(128) NOT NULL,
              `service_id` varchar(128) NOT NULL,
              `comment` varchar(1024) DEFAULT NULL,
              `row_created` timestamp NULL DEFAULT NULL,
              `row_updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
              PRIMARY KEY (`row_id`)
            );
       """)
    op.create_table('user_preference',
        sa.Column('row_id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('user_row_id', sa.Integer(), nullable=False),
        sa.Column('preference_type', sa.VARCHAR(length=128), nullable=False),
        sa.Column('communication_type', sa.VARCHAR(length=128), nullable=False),
        sa.Column('source', sa.VARCHAR(length=128), nullable=False),
        sa.Column('opt_out_reason', sa.VARCHAR(length=256), nullable=True),
        sa.Column('status', sa.BOOLEAN(), nullable=False),
        sa.Column('created_on', mysql.TIMESTAMP(), nullable=False),
        sa.Column('updated_on', mysql.TIMESTAMP(), nullable=False),
        sa.ForeignKeyConstraint(['user_row_id'], ['user.row_id'], onupdate='CASCADE', ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('row_id'),
        sa.UniqueConstraint('preference_type', 'communication_type', 'source', name='uq_usr_pref')
    )
github elemental-lf / benji / src / benji / database.py View on Github external
return DereferencedBlock(
            uid=self.uid,
            version_id=self.version_id,
            idx=self.idx,
            checksum=self.checksum,
            size=self.size,
            valid=self.valid,
        )


class DeletedBlock(Base, ReprMixIn):
    __tablename__ = 'deleted_blocks'

    REPR_SQL_ATTR_SORT_FIRST = ['storage_id', 'uid']

    date = sqlalchemy.Column("date", BenjiDateTime, nullable=False)
    id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True, autoincrement=True, nullable=False)
    storage_id = sqlalchemy.Column(sqlalchemy.Integer, sqlalchemy.ForeignKey('storages.id'), nullable=False)
    # Force loading of storage so that the attribute can be accessed even when there is no associated session anymore.
    storage = sqlalchemy.orm.relationship('Storage', lazy='joined')

    uid_left = sqlalchemy.Column(sqlalchemy.Integer, nullable=False)
    uid_right = sqlalchemy.Column(sqlalchemy.Integer, nullable=False)

    uid = sqlalchemy.orm.composite(BlockUid, uid_left, uid_right, comparator_factory=BlockUidComparator)
    __table_args__ = (sqlalchemy.Index(None, 'uid_left', 'uid_right'),)

    @classmethod
    def get_unused_block_uids(cls, dt: int = 3600) -> Iterator[Dict[str, Set[BlockUid]]]:
        rounds = 0
        false_positives_count = 0
        hit_list_count = 0
github IntegralDefense / ACE / lib / saq / database.py View on Github external
ForeignKey('users.id'),
        nullable=False)

    key = Column(
        String,
        nullable=False)

    result = Column(
        String,
        nullable=True)

    comment = Column(
        String,
        nullable=True)

    successful = Column(
        BOOLEAN,
        nullable=True,
        default=False)

class Workload(Base):

    __tablename__ = 'workload'

    id = Column(
        Integer,
        primary_key=True)

    uuid = Column(
        String(36), 
        nullable=False,
        unique=True)
github agdsn / pycroft / pycroft / model / host.py View on Github external
raise InvalidMACAddressException("MAC address '"+mac_address+"' is not valid")
        if int(mac_address[0:2], base=16) & 1:
            raise MulticastFlagException("Multicast bit set in MAC address")
        return mac_address

    host = relationship(Host,
                        backref=backref("interfaces",
                                        cascade="all, delete-orphan"))


# See the `SwitchPort.default_vlans` relationship
switch_port_default_vlans = Table(
    'switch_port_default_vlans', ModelBase.metadata,
    Column('switch_port_id', Integer, ForeignKey('switch_port.id', ondelete='CASCADE'),
           index=True),
    Column('vlan_id', Integer, ForeignKey('vlan.id', ondelete='CASCADE'),
           index=True),
)


class SwitchPort(IntegerIdModel):
    switch_id = Column(Integer, ForeignKey(Switch.host_id, ondelete="CASCADE"),
                       nullable=False, index=True)
    switch = relationship(Switch,
                          backref=backref("ports",
                                        cascade="all, delete-orphan"))
    name = Column(String(64), nullable=False)
    #: These are the VLANs that should theoretically be available at
    #: this switch port.  It is only used to calculate the pool of IPs
    #: to choose from e.g. when adding a user or migrating a host, and
    #: does not influence any functionality beyond that.
    default_vlans = relationship('VLAN', secondary='switch_port_default_vlans',