Python sqlalchemy.Integer() Examples

The following are code examples for showing how to use sqlalchemy.Integer(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: eventor   Author: Acrisel   File: dbschema.py    (license) View Source Project 7 votes vote down vote up
def info_table(base):
    class Info(base):
        __tablename__ = 'Info'
        
        id_ = Column(Integer, Sequence('trigger_id_seq'), primary_key=True)
        run_id=Column(String, nullable=False)
        name=Column(String, nullable=False)
        value=Column(String, nullable=True)
        
        __table_args__ = (
                UniqueConstraint('run_id', 'name'),
                )
    
        def __repr__(self):
            return "<Info(run_id='%s', name='%s', value='%s')>" % (self.run_id, self.name, self.value)
        
    return Info 
Example 2
Project: eventor   Author: Acrisel   File: dbschema.py    (license) View Source Project 7 votes vote down vote up
def delay_table(base):
    class Delay(base):
        __tablename__ = 'Delay'
        
        id_=Column(Integer, Sequence('delay_id_seq'), primary_key=True)
        run_id = Column(String, default='')
        delay_id = Column(String,)
        sequence = Column(Integer,)
        recovery = Column(Integer,)
        seconds = Column(BigInteger, nullable=True)
        active = Column(Boolean, default=False)
        activated = Column(DateTime(), nullable=True,) 
        updated = Column(DateTime(), default=datetime.utcnow) 
        
        __table_args__ = (
                UniqueConstraint('run_id', 'delay_id', 'sequence', 'recovery'),
                )
    
        def __repr__(self):
            return "<Delay(id='%s', run_id='%s', delay_id='%s', delay='%s', active='%s', activated='%s')>" % (
                self.id_, self.run_id, self.delay_id, self.seconds, self.active, self.activated)
    
    return Delay 
Example 3
Project: podigger   Author: perna   File: 012722a93d11_.py    (license) View Source Project 7 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('topic_suggestion',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('is_recorded', sa.Boolean(), nullable=False),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_topic_suggestion_id'), 'topic_suggestion', ['id'], unique=False)
    op.create_index(op.f('ix_topic_suggestion_title'), 'topic_suggestion', ['title'], unique=False)
    op.create_index(op.f('ix_episode_id'), 'episode', ['id'], unique=False)
    op.create_index(op.f('ix_podcast_id'), 'podcast', ['id'], unique=False)
    op.create_index(op.f('ix_popular_term_id'), 'popular_term', ['id'], unique=False)
    op.create_index(op.f('ix_tag_id'), 'tag', ['id'], unique=False)
    ### end Alembic commands ### 
Example 4
Project: zipline-chinese   Author: zhanghan1990   File: asset_db_schema.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def _equities_table_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'equities',
        metadata,
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('symbol', sa.Text),
        sa.Column('company_symbol', sa.Text, index=True),
        sa.Column('share_class_symbol', sa.Text),
        sa.Column('fuzzy_symbol', sa.Text, index=True),
        sa.Column('asset_name', sa.Text),
        sa.Column('start_date', sa.Integer, default=0, nullable=False),
        sa.Column('end_date', sa.Integer, nullable=False),
        sa.Column('first_traded', sa.Integer, nullable=False),
        sa.Column('auto_close_date', sa.Integer),
        sa.Column('exchange', sa.Text),
    ) 
Example 5
Project: zipline-chinese   Author: zhanghan1990   File: asset_db_schema.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def _futures_root_symbols_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'futures_root_symbols',
        metadata,
        sa.Column(
            'root_symbol',
            sa.Text,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('root_symbol_id', sa.Integer),
        sa.Column('sector', sa.Text),
        sa.Column('description', sa.Text),
        sa.Column(
            'exchange',
            sa.Text,
            sa.ForeignKey('futures_exchanges.exchange'),
        ),
    ) 
Example 6
Project: zipline-chinese   Author: zhanghan1990   File: asset_db_schema.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def _version_table_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'version_info',
        metadata,
        sa.Column(
            'id',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column(
            'version',
            sa.Integer,
            unique=True,
            nullable=False,
        ),
        # This constraint ensures a single entry in this table
        sa.CheckConstraint('id <= 1'),
    ) 
Example 7
Project: Flask_Blog   Author: sugarguo   File: test_insert.py    (GNU General Public License v3.0) View Source Project 6 votes vote down vote up
def define_tables(cls, metadata):
        Table('autoinc_pk', metadata,
              Column('id', Integer, primary_key=True,
                     test_needs_autoincrement=True),
              Column('data', String(50))
              )
        Table('manual_pk', metadata,
              Column('id', Integer, primary_key=True, autoincrement=False),
              Column('data', String(50))
              )
        Table('includes_defaults', metadata,
              Column('id', Integer, primary_key=True,
                     test_needs_autoincrement=True),
              Column('data', String(50)),
              Column('x', Integer, default=5),
              Column('y', Integer,
                     default=literal_column("2", type_=Integer) + literal(2))) 
Example 8
Project: FRG-Crowdsourcing   Author: 97amarnathk   File: d1add5e3e65e_projects_stats.py    (GNU Affero General Public License v3.0) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'project_stats',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('project_id', sa.Integer, sa.ForeignKey('project.id',
                                                          ondelete='CASCADE')),
        sa.Column('n_tasks', sa.Integer, default=0),
        sa.Column('n_task_runs', sa.Integer, default=0),
        sa.Column('n_results', sa.Integer, default=0),
        sa.Column('n_volunteers', sa.Integer, default=0),
        sa.Column('n_completed_tasks', sa.Integer, default=0),
        sa.Column('overall_progress', sa.Integer, default=0),
        sa.Column('average_time', sa.Float, default=0),
        sa.Column('n_blogposts', sa.Integer, default=0),
        sa.Column('last_activity', sa.Text, default=make_timestamp),
        sa.Column('info', JSON, nullable=False)
    ) 
Example 9
Project: cyborg   Author: openstack   File: f50980397351_initial_migration.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'accelerators',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.Column('description', sa.Text(), nullable=True),
        sa.Column('project_id', sa.String(length=36), nullable=True),
        sa.Column('user_id', sa.String(length=36), nullable=True),
        sa.Column('device_type', sa.Text(), nullable=False),
        sa.Column('acc_type', sa.Text(), nullable=False),
        sa.Column('acc_capability', sa.Text(), nullable=False),
        sa.Column('vendor_id', sa.Text(), nullable=False),
        sa.Column('product_id', sa.Text(), nullable=False),
        sa.Column('remotable', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_ENGINE='InnoDB',
        mysql_DEFAULT_CHARSET='UTF8'
    ) 
Example 10
Project: tuning-box   Author: openstack   File: a86472389a70_remove_hierarchy_for_level_values.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def downgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    table_name = table_prefix + 'environment_hierarchy_level_value'
    with op.batch_alter_table(table_name) as batch:
        batch.drop_constraint(
            table_name + '_level_id_value_unique',
            type_='unique'
        )

        batch.drop_constraint(
            table_name + '_level_id_fkey',
            type_='foreignkey'
        )
        batch.create_foreign_key(
            table_name + '_level_id_fkey',
            table_prefix + 'environment_hierarchy_level',
            ['level_id'], ['id']
        )

        batch.add_column(sa.Column('parent_id', sa.Integer(), nullable=True))
        batch.create_foreign_key(
            table_name + '_parent_id_fkey',
            table_name,
            ['parent_id'], ['id']
        ) 
Example 11
Project: tuning-box   Author: openstack   File: 3b2a0f134e45_switch_to_new_api.py    (Apache License 2.0) View Source Project 6 votes vote down vote up
def upgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    op.drop_table(table_prefix + 'template')
    table_name = table_prefix + 'environment_schema_values'
    with op.batch_alter_table(table_name) as batch:
        batch.drop_constraint(table_name + '_schema_id_fkey', 'foreignkey')
        batch.alter_column(
            'schema_id',
            new_column_name='resource_definition_id',
            existing_type=sa.Integer(),
        )
    op.rename_table(table_name, table_prefix + 'resource_values')
    op.rename_table(table_prefix + 'schema',
                    table_prefix + 'resource_definition')
    with op.batch_alter_table(table_prefix + 'resource_definition') as batch:
        batch.drop_column('namespace_id')
    op.drop_table(table_prefix + 'namespace')
    table_name = table_prefix + 'resource_values'
    with op.batch_alter_table(table_name) as batch:
        batch.create_foreign_key(
            table_name + '_resource_definition_id_fkey',
            table_prefix + 'resource_definition',
            ['resource_definition_id'],
            ['id'],
        ) 
Example 12
Project: bit   Author: codesmart-co   File: 4ad33f99723a_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('bit_facebook_daily_ad_insights_impression_device',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('account_id', sa.String(length=255), nullable=True),
    sa.Column('campaign_id', sa.String(length=255), nullable=True),
    sa.Column('adset_id', sa.String(length=255), nullable=True),
    sa.Column('campaign_name', sa.String(length=255), nullable=True),
    sa.Column('spend', sa.Numeric(), nullable=True),
    sa.Column('cost_per_unique_click', sa.Numeric(), nullable=True),
    sa.Column('unique_clicks', sa.Integer(), nullable=True),
    sa.Column('unique_impressions', sa.Integer(), nullable=True),
    sa.Column('unique_social_clicks', sa.Integer(), nullable=True),
    sa.Column('unique_social_impressions', sa.Integer(), nullable=True),
    sa.Column('website_clicks', sa.Integer(), nullable=True),
    sa.Column('date_start', sa.DateTime(), nullable=True),
    sa.Column('date_stop', sa.DateTime(), nullable=True),
    sa.Column('impression_device', sa.String(length=255), nullable=True),
    sa.Column('ad_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['ad_id'], ['bit_facebook_ad.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_bit_facebook_daily_ad_insights_impression_device_impression_device'), 'bit_facebook_daily_ad_insights_impression_device', ['impression_device'], unique=False)
    # ### end Alembic commands ### 
Example 13
Project: sqlalchemy-media   Author: pylover   File: test_delete_orphan.py    (license) View Source Project 6 votes vote down vote up
def test_delete_orphan(self):

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(File.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()
        person1 = Person()
        self.assertIsNone(person1.cv)

        with StoreManager(session, delete_orphan=True):
            # First file before commit
            person1.cv = File.create_from(BytesIO(b'Simple text.'), content_type='text/plain', extension='.txt')
            self.assertIsInstance(person1.cv, File)
            first_filename = join(self.temp_path, person1.cv.path)
            self.assertTrue(exists(first_filename))
            person1.cv = File.create_from(BytesIO(b'Second simple text.'))
            second_filename = join(self.temp_path, person1.cv.path)
            self.assertTrue(exists(first_filename))
            self.assertTrue(exists(second_filename))
            session.add(person1)
            session.commit()
            self.assertFalse(exists(first_filename))
            self.assertTrue(exists(second_filename)) 
Example 14
Project: sqlalchemy-media   Author: pylover   File: test_delete_orphan.py    (license) View Source Project 6 votes vote down vote up
def test_without_delete_orphan(self):

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(File.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()
        person1 = Person()

        with StoreManager(session):

            # First file before commit
            person1.cv = File.create_from(BytesIO(b'Simple text.'), content_type='text/plain', extension='.txt')
            first_filename = join(self.temp_path, person1.cv.path)
            person1.cv = File.create_from(BytesIO(b'Second simple text.'))
            second_filename = join(self.temp_path, person1.cv.path)
            session.add(person1)
            session.commit()
            self.assertTrue(exists(first_filename))
            self.assertTrue(exists(second_filename)) 
Example 15
Project: sqlalchemy-media   Author: pylover   File: test_delete_orphan.py    (license) View Source Project 6 votes vote down vote up
def test_delete_orphan_image(self):
        """
        https://github.com/pylover/sqlalchemy-media/issues/81
        """
        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            pic = Column(Image.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()

        with StoreManager(session, delete_orphan=True):
            person1 = Person()
            person1.pic = Image.create_from(self.cat_jpeg)
            first_filename = join(self.temp_path, person1.pic.path)
            session.commit()
            self.assertTrue(exists(first_filename))

            person1.pic = Image.create_from(self.dog_jpeg)
            session.commit()
            self.assertFalse(exists(first_filename)) 
Example 16
Project: sqlalchemy-media   Author: pylover   File: test_decorator.py    (license) View Source Project 6 votes vote down vote up
def test_decorator(self):

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            image = Column(Image.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()

        person1 = Person()
        self.assertIsNone(person1.image)

        @store_manager(session)
        def add_image():
            person1.image = Image.create_from(self.dog_jpeg)
            self.assertEqual(person1.image.content_type, 'image/jpeg')
            self.assertEqual(person1.image.extension, '.jpg')
            self.assertTrue(exists(join(self.temp_path, person1.image.path)))

            person1.image = Image.create_from(self.dog_png)
            self.assertEqual(person1.image.content_type, 'image/png')
            self.assertTrue(exists(join(self.temp_path, person1.image.path)))

        add_image() 
Example 17
Project: sqlalchemy-media   Author: pylover   File: test_file.py    (license) View Source Project 6 votes vote down vote up
def test_file_size_limit(self):

        class LimitedFile(File):
            __min_length__ = 20
            __max_length__ = 30

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(LimitedFile.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()

        person1 = Person()
        person1.cv = LimitedFile()

        with StoreManager(session):

            # MaximumLengthIsReachedError, MinimumLengthIsNotReachedError
            self.assertRaises(MinimumLengthIsNotReachedError, person1.cv.attach, BytesIO(b'less than 20 chars!'))
            self.assertRaises(MaximumLengthIsReachedError, person1.cv.attach,
                              BytesIO(b'more than 30 chars!............')) 
Example 18
Project: sqlalchemy-media   Author: pylover   File: test_file.py    (license) View Source Project 6 votes vote down vote up
def test_attribute_type_assertion(self):
        class MyAttachmentType(File):
            pass

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(MyAttachmentType.as_mutable(Json), nullable=True)

        person1 = Person()

        def set_invalid_type():
            person1.cv = list()

        def set_invalid_type_via_constructor():
            Person(cv=67)

        self.assertRaises(TypeError, set_invalid_type)
        self.assertRaises(TypeError, set_invalid_type_via_constructor) 
Example 19
Project: sqlalchemy-media   Author: pylover   File: test_file.py    (license) View Source Project 6 votes vote down vote up
def test_attribute_type_coercion(self):

        class MyAttachmentType(File):
            __auto_coercion__ = True
            pass

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(MyAttachmentType.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()
        with StoreManager(session):
            person1 = Person()
            person1.cv = BytesIO(b'Simple text')
            self.assertIsInstance(person1.cv, MyAttachmentType)

            person2 = Person(cv=BytesIO(b'Simple text'))
            self.assertIsInstance(person2.cv, MyAttachmentType)
            session.add(person2)
            session.commit() 
Example 20
Project: sqlalchemy-media   Author: pylover   File: test_file.py    (license) View Source Project 6 votes vote down vote up
def test_overwrite(self):
        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(File.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()
        person1 = Person(cv=File())
        self.assertIsInstance(person1.cv, File)
        with StoreManager(session):
            person1.cv.attach(BytesIO(b'Simple text'))
            cv_filename = join(self.temp_path, person1.cv.path)
            self.assertTrue(exists(cv_filename))
            session.add(person1)
            session.commit()

            # Now overwriting the file
            person1 = session.query(Person).filter(Person.id == person1.id).one()
            person1.cv.attach(BytesIO(b'Another simple text'), overwrite=True)
            self.assertTrue(exists(cv_filename))
            session.commit()
            self.assertTrue(exists(cv_filename)) 
Example 21
Project: sqlalchemy-media   Author: pylover   File: test_file.py    (license) View Source Project 6 votes vote down vote up
def test_content_type_validator(self):

        class PDFFile(File):
            __pre_processors__ = [
                MagicAnalyzer(),
                ContentTypeValidator(['application/pdf', 'image/jpeg'])
            ]

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            cv = Column(PDFFile.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()
        person1 = Person(cv=PDFFile())
        with StoreManager(session):
            self.assertIsNotNone(person1.cv.attach(self.cat_jpeg))
            self.assertRaises(ContentTypeValidationError, person1.cv.attach, BytesIO(b'Simple text')) 
Example 22
Project: sqlalchemy-media   Author: pylover   File: test_image.py    (license) View Source Project 6 votes vote down vote up
def test_image(self):

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            image = Column(Image.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()

        # person1 = Person(name='person1')
        person1 = Person()
        self.assertIsNone(person1.image)

        with StoreManager(session):
            person1.image = Image.create_from(self.dog_jpeg)
            self.assertEqual(person1.image.content_type, 'image/jpeg')
            self.assertEqual(person1.image.extension, '.jpg')
            self.assertTrue(exists(join(self.temp_path, person1.image.path)))

            person1.image = Image.create_from(self.dog_png)
            self.assertEqual(person1.image.content_type, 'image/png')
            self.assertTrue(exists(join(self.temp_path, person1.image.path))) 
Example 23
Project: sqlalchemy-media   Author: pylover   File: test_image.py    (license) View Source Project 6 votes vote down vote up
def test_pre_process(self):

        class Banner(Image):
            __pre_processors__ = ImageProcessor(fmt='jpeg', width=300)

        class Person(self.Base):
            __tablename__ = 'person'
            id = Column(Integer, primary_key=True)
            image = Column(Banner.as_mutable(Json), nullable=True)

        session = self.create_all_and_get_session()

        # person1 = Person(name='person1')
        person1 = Person()
        self.assertIsNone(person1.image)

        with StoreManager(session):
            person1.image = Banner.create_from(self.cat_png)
            self.assertEqual(person1.image.content_type, 'image/jpeg') 
Example 24
Project: anormbookmarker   Author: jakeogh   File: TagClassConstructor.py    (license) View Source Project 6 votes vote down vote up
def __new__(cls, mapper_to_bookmark):
        class_attr = {}
        class_attr['id'] = Column(Integer, primary_key=True)
        class_attr['tagwords'] = relationship("TagWord", backref='tag') # list of TagWord instances
        class_attr['parents'] = relationship('Tag',
                                             secondary=tag_relationship,
                                             primaryjoin=tag_relationship.c.tag_id == class_attr['id'],
                                             secondaryjoin=tag_relationship.c.tag_parent_id == class_attr['id'],
                                             backref="children")
        target_class_name = mapper_to_bookmark.__name__
        target_name = target_class_name.lower().split('.')[-1] # 'filename' usually

        class_attr['target_class_name'] = target_class_name
        class_attr['target_name'] = target_name

        class_attr['__init__'] = init
        class_attr['__repr__'] = display
        class_attr['construct'] = construct         # @classmethod
        class_attr['tag'] = build_tag               # @property
        class_attr[target_name+'s'] = tag_targets   # @hybrid_property
        class_attr['words'] = words                 # @hybrid_property
        return type('Tag', (BASE,), class_attr) 
Example 25
Project: eventor   Author: Acrisel   File: dbschema.py    (license) View Source Project 6 votes vote down vote up
def trigger_table(base):
    class Trigger(base):
        __tablename__ = 'Trigger'
        
        id_ = Column(Integer, Sequence('trigger_id_seq'), primary_key=True)
        run_id = Column(String, nullable=False, default='')
        event_id = Column(String, nullable=False)
        sequence = Column(Integer, nullable=False)
        recovery = Column(Integer, nullable=False, default=0)
        created = Column(DateTime(), default=datetime.utcnow) 
        acted = Column(DateTime(), nullable=True) 
    
        def __repr__(self):
            return "<Trigger(id='%s', run_id='%s', event_id='%s', sequence='%s', recovery='%s', created='%s', acted='%s')>" % (
                self.id_, self.run_id, self.event_id, self.sequence, self.recovery, self.created, self.acted)
    
    return Trigger 
Example 26
Project: fuel-plugin-dns-updater   Author: openstack   File: db_setup.py    (license) View Source Project 6 votes vote down vote up
def init_tables():
    db_instance = Table("instance", dbmeta,
          Column("id", Integer, primary_key=True),
          Column("ip", String(20)),
          Column("name", String(90)),
          Column("uuid", String(40)),
          Column("state", String(90)),
          Column("dns_domain", String(90)),
          Column("created_at", DateTime),
          Column("updated_at", DateTime),
          Column("deleted_at", DateTime)
    )
    db_event = Table("event", dbmeta,
          #will be used for synchronization
          Column("id", Integer, primary_key=True),
          Column("fk_instance_id", Integer, ForeignKey("instance.id")),
          Column("type", String(24)),#enum
          Column("description", String(90)),
          Column("date", DateTime)
    )
    dbmeta.drop_all(dbengine)
    dbmeta.create_all(dbengine) 
Example 27
Project: Leics   Author: LeicsFrameWork   File: 948333640f64_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('roles',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('default', sa.Boolean(), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_index(op.f('ix_roles_default'), 'roles', ['default'], unique=False)
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=164), nullable=True),
    sa.Column('email', sa.String(length=164), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.Column('password_hash', sa.String(length=164), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
    ### end Alembic commands ### 
Example 28
Project: QXSConsolas   Author: qxsch   File: test_insert.py    (license) View Source Project 6 votes vote down vote up
def define_tables(cls, metadata):
        Table('autoinc_pk', metadata,
              Column('id', Integer, primary_key=True,
                     test_needs_autoincrement=True),
              Column('data', String(50))
              )
        Table('manual_pk', metadata,
              Column('id', Integer, primary_key=True, autoincrement=False),
              Column('data', String(50))
              )
        Table('includes_defaults', metadata,
              Column('id', Integer, primary_key=True,
                     test_needs_autoincrement=True),
              Column('data', String(50)),
              Column('x', Integer, default=5),
              Column('y', Integer,
                     default=literal_column("2", type_=Integer) + literal(2))) 
Example 29
Project: podigger   Author: perna   File: 5c5dc0258b2f_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('episode',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(), nullable=False),
    sa.Column('link', sa.String(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('published', sa.DateTime(), nullable=True),
    sa.Column('enclosure', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('podcast_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['podcast_id'], ['podcast.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('link'),
    sa.UniqueConstraint('title')
    )
    op.create_index(op.f('ix_podcast_feed'), 'podcast', ['feed'], unique=True)
    op.create_index(op.f('ix_podcast_name'), 'podcast', ['name'], unique=True)
    ### end Alembic commands ### 
Example 30
Project: podigger   Author: perna   File: 34d97cbc759e_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('role',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=255), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('confirmed_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('roles_users',
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('role_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['role_id'], ['role.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
    )
    ### end Alembic commands ### 
Example 31
Project: 1ibrary-gzhu   Author: 1ibrary   File: 525c4fa30db4_.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('hot_books',
    sa.Column('book_id', sa.Integer(), nullable=False),
    sa.Column('book_author', sa.Text(), nullable=True),
    sa.Column('book_cover', sa.Text(), nullable=True),
    sa.Column('book_rate', sa.Integer(), nullable=True),
    sa.Column('book_content', sa.Text(), nullable=True),
    sa.Column('book_publish', sa.Text(), nullable=True),
    sa.Column('book_last_number', sa.Integer(), nullable=True),
    sa.Column('book_key', sa.String(length=13), nullable=True),
    sa.Column('book_db_id', sa.Integer(), nullable=True),
    sa.Column('book_title', sa.Text(), nullable=True),
    sa.Column('book_place', sa.Text(), nullable=True),
    sa.Column('detail_data', sa.Text(), nullable=True),
    sa.Column('hot_id', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('book_id'),
    sa.UniqueConstraint('book_db_id')
    )
    op.create_index(op.f('ix_hot_books_book_key'), 'hot_books', ['book_key'], unique=False)
    # ### end Alembic commands ### 
Example 32
Project: zun   Author: openstack   File: 10d65e285a59_create_volume_mapping_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'volume_mapping',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(36), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('volume_id', sa.String(36), nullable=False),
        sa.Column('volume_provider', sa.String(36), nullable=False),
        sa.Column('container_uuid', sa.String(36), nullable=False),
        sa.Column('container_path', sa.String(length=255), nullable=True),
        sa.Column('connection_info', MediumText(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_volume0uuid'),
    ) 
Example 33
Project: zun   Author: openstack   File: 9fe371393a24_create_table_container.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('image', sa.String(length=255), nullable=True),
        sa.Column('command', sa.String(length=255), nullable=True),
        sa.Column('status', sa.String(length=20), nullable=True),
        sa.Column('environment', zun.db.sqlalchemy.models.JSONEncodedDict(),
                  nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_container0uuid')
    ) 
Example 34
Project: zun   Author: openstack   File: a251f1f61217_create_capsule_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'capsule',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('capsule_version', sa.String(length=255), nullable=True),
        sa.Column('kind', sa.String(length=36), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('restart_policy', sa.String(length=255), nullable=True),
        sa.Column('host_selector', sa.String(length=255), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('status', sa.String(length=255), nullable=True),
        sa.Column('status_reason', sa.Text(), nullable=True),
        sa.Column('message', models.JSONEncodedDict(), nullable=True),
        sa.Column('spec', models.JSONEncodedDict(), nullable=True),
        sa.Column('cpu', sa.Float(), nullable=True),
        sa.Column('memory', sa.String(length=255), nullable=True),
        sa.Column('meta_name', sa.String(length=255), nullable=True),
        sa.Column('meta_labels', models.JSONEncodedList(), nullable=True),
        sa.Column('containers_uuids', models.JSONEncodedList(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
    ) 
Example 35
Project: zun   Author: openstack   File: a9a92eebd9a8_create_table_zun_service.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table(
        'zun_service',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('report_count', sa.Integer(), nullable=False),
        sa.Column('host', sa.String(length=255), nullable=True),
        sa.Column('binary', sa.String(length=255), nullable=True),
        sa.Column('disabled', sa.Boolean(), nullable=True),
        sa.Column('disabled_reason', sa.String(length=255), nullable=True),
        sa.Column('last_seen_up', sa.DateTime(), nullable=True),
        sa.Column('forced_down', sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('host', 'binary',
                            name='uniq_zun_service0host0binary')
    ) 
Example 36
Project: xiaodi   Author: shenaishiren   File: mysql.py    (license) View Source Project 6 votes vote down vote up
def _init_cls(cls):
    setattr(cls, '__tablename__', cls.__name__)
    setattr(cls, 'id', Column(Integer, primary_key=True, autoincrement=True))
    for _str in getattr(cls, 'stringV', []):
        setattr(cls, _str, Column(String(DB_STRING_LENGTH)))
    for _int in getattr(cls, 'integerV', []):
        setattr(cls, _int, Column(Integer))
    for _bool in getattr(cls, 'boolV', []):
        setattr(cls, _bool, Column(Boolean))
    for _float in getattr(cls, 'floatV', []):
        setattr(cls, _float, Column(Float))
    for _time in getattr(cls, 'timeV', []):
        setattr(cls, _time, Column(DateTime, default=datetime.utcnow))
    for key, value in getattr(cls, 'foreignKeyV', {}).iteritems():
        setattr(cls, key, Column(Integer, ForeignKey(value), primary_key=True))
    setattr(cls, 'to_json', _convert_attr_to_dict) 
Example 37
Project: retrospective-bot   Author: bayesimpact   File: 574083c098fc_create_retrospective_items_table.py    (license) View Source Project 6 votes vote down vote up
def upgrade():
    op.create_table('sprints',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_name', sa.Unicode(), nullable=True),
        sa.Column('creation_date', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'))

    op.create_table('retrospective_items',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('sprint_id', sa.Integer(), nullable=False),
        sa.Column('category', sa.Unicode(), nullable=True),
        sa.Column('text', sa.Unicode(), nullable=True),
        sa.Column('user_name', sa.Unicode(), nullable=True),
        sa.Column('creation_date', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_retrospective_items'), 'retrospective_items', ['sprint_id', 'category'], unique=False) 
Example 38
Project: fuel-nailgun-extension-iac   Author: openstack   File: e3b840e64e53_init.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
def upgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    op.create_table(
        table_prefix + 'repos',
        sa.Column('id', sa.Integer(), nullable=False, primary_key=True),
        sa.Column('repo_name', sa.Unicode(100), nullable=False),
        sa.Column('env_id', sa.Integer(), nullable=False),
        sa.Column('git_url', sa.String(255),
                  server_default='', nullable=False),
        sa.Column('ref', sa.String(255),
                  server_default='', nullable=False),
        sa.Column('user_key', sa.String(255),
                  server_default='', nullable=False),
        sa.UniqueConstraint('env_id', name='_env_id_unique')) 
Example 39
Project: fuel-nailgun-extension-iac   Author: openstack   File: 8736ad38ca31_add_whitelist_table.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
def upgrade():
    table_prefix = context.config.get_main_option('table_prefix')
    op.create_table(
        table_prefix + 'changes_whitelist',
        sa.Column('id', sa.Integer(), nullable=False, primary_key=True),
        sa.Column('env_id', sa.Integer(), nullable=False),
        sa.Column('rule', sa.String(255),
                  server_default='', nullable=False)
    ) 
Example 40
Project: zipline-chinese   Author: zhanghan1990   File: asset_db_schema.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
def _futures_contracts_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'futures_contracts',
        metadata,
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True,
        ),
        sa.Column('symbol', sa.Text, unique=True, index=True),
        sa.Column(
            'root_symbol',
            sa.Text,
            sa.ForeignKey('futures_root_symbols.root_symbol'),
            index=True
        ),
        sa.Column('asset_name', sa.Text),
        sa.Column('start_date', sa.Integer, default=0, nullable=False),
        sa.Column('end_date', sa.Integer, nullable=False),
        sa.Column('first_traded', sa.Integer, nullable=False),
        sa.Column(
            'exchange',
            sa.Text,
            sa.ForeignKey('futures_exchanges.exchange'),
        ),
        sa.Column('notice_date', sa.Integer, nullable=False),
        sa.Column('expiration_date', sa.Integer, nullable=False),
        sa.Column('auto_close_date', sa.Integer, nullable=False),
        sa.Column('multiplier', sa.Float),
        sa.Column('tick_size', sa.Float),
    ) 
Example 41
Project: zipline-chinese   Author: zhanghan1990   File: asset_db_schema.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
def _asset_router_schema(metadata):
    # NOTE: When modifying this schema, update the ASSET_DB_VERSION value
    return sa.Table(
        'asset_router',
        metadata,
        sa.Column(
            'sid',
            sa.Integer,
            unique=True,
            nullable=False,
            primary_key=True),
        sa.Column('asset_type', sa.Text),
    ) 
Example 42
Project: zlktqa   Author: NunchakusHuang   File: a524f97f269b_.py    (license) View Source Project 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.String(length=100), nullable=False),
    sa.Column('username', sa.String(length=100), nullable=False),
    sa.Column('telephone', sa.String(length=11), nullable=False),
    sa.Column('_password', sa.String(length=100), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('questions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=100), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('author_id', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('answers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('content', sa.Text(), nullable=False),
    sa.Column('question_id', sa.Integer(), nullable=True),
    sa.Column('author_id', sa.String(length=100), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['question_id'], ['questions.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
Example 43
Project: tasker   Author: DominikPott   File: model.py    (license) View Source Project 5 votes vote down vote up
def task_association_id(cls):
        return Column(Integer, ForeignKey('task_association.id')) 
Example 44
Project: Flask_Blog   Author: sugarguo   File: base.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def __repr__(self):
        return util.generic_repr(self, to_inspect=[_IntegerType,
                                                   _NumericType,
                                                   sqltypes.Integer]) 
Example 45
Project: Flask_Blog   Author: sugarguo   File: base.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def visit_typeclause(self, typeclause, type_=None):
        if type_ is None:
            type_ = typeclause.type.dialect_impl(self.dialect)
        if isinstance(type_, sqltypes.TypeDecorator):
            return self.visit_typeclause(typeclause, type_.impl)
        elif isinstance(type_, sqltypes.Integer):
            if getattr(type_, 'unsigned', False):
                return 'UNSIGNED INTEGER'
            else:
                return 'SIGNED INTEGER'
        elif isinstance(type_, sqltypes.TIMESTAMP):
            return 'DATETIME'
        elif isinstance(type_, (sqltypes.DECIMAL, sqltypes.DateTime,
                                sqltypes.Date, sqltypes.Time)):
            return self.dialect.type_compiler.process(type_)
        elif isinstance(type_, sqltypes.String) \
                and not isinstance(type_, (ENUM, SET)):
            adapted = CHAR._adapt_string_for_cast(type_)
            return self.dialect.type_compiler.process(adapted)
        elif isinstance(type_, sqltypes._Binary):
            return 'BINARY'
        elif isinstance(type_, sqltypes.NUMERIC):
            return self.dialect.type_compiler.process(
                type_).replace('NUMERIC', 'DECIMAL')
        else:
            return None 
Example 46
Project: Flask_Blog   Author: sugarguo   File: test_update_delete.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def define_tables(cls, metadata):
        Table('plain_pk', metadata,
              Column('id', Integer, primary_key=True),
              Column('data', String(50))
              ) 
Example 47
Project: Flask_Blog   Author: sugarguo   File: test_select.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def define_tables(cls, metadata):
        Table("some_table", metadata,
              Column('id', Integer, primary_key=True),
              Column('x', Integer),
              Column('y', Integer),
              Column('q', String(50)),
              Column('p', String(50))
              ) 
Example 48
Project: Flask_Blog   Author: sugarguo   File: test_reflection.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def define_tables(cls, metadata):
        Table('test_table', metadata,
              Column('id', Integer, primary_key=True),
              Column('data', String(50))
              ) 
Example 49
Project: Flask_Blog   Author: sugarguo   File: test_reflection.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def test_nullable_reflection(self):
        t = Table('t', self.metadata,
                  Column('a', Integer, nullable=True),
                  Column('b', Integer, nullable=False))
        t.create()
        eq_(
            dict(
                (col['name'], col['nullable'])
                for col in inspect(self.metadata.bind).get_columns('t')
            ),
            {"a": True, "b": False}
        ) 
Example 50
Project: Flask_Blog   Author: sugarguo   File: test_insert.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def define_tables(cls, metadata):
        Table('autoinc_pk', metadata,
              Column('id', Integer, primary_key=True,
                     test_needs_autoincrement=True),
              Column('data', String(50))
              )