我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用sqlalchemy.dialects.mysql.INTEGER。
def _gen_sa_table(sectype, metadata=None): """Generate SQLAlchemy Table object by sectype. """ if metadata is None: metadata = MetaData() table = Table( sectype, metadata, Column('Symbol', String(20), primary_key=True), Column('DataType', String(20), primary_key=True), Column('BarSize', String(10), primary_key=True), Column('TickerTime', DateTime(), primary_key=True), Column('opening', Float(10, 2)), Column('high', Float(10, 2)), Column('low', Float(10, 2)), Column('closing', Float(10, 2)), Column('volume', mysqlINTEGER(unsigned=True)), Column('barcount', mysqlINTEGER(unsigned=True)), Column('average', Float(10, 2)) ) return table
def upgrade(): # When making changes to a column that has a foreign key, we need to drop # and then re-add the constraint op.execute('DELETE FROM txn_reconciles WHERE txn_id IS NULL;') op.execute('LOCK TABLES txn_reconciles WRITE, transactions WRITE;') op.drop_constraint('fk_txn_reconciles_txn_id_transactions', 'txn_reconciles', type_='foreignkey') op.alter_column( 'txn_reconciles', 'txn_id', existing_type=mysql.INTEGER(display_width=11), nullable=False ) op.create_foreign_key('fk_txn_reconciles_txn_id_transactions', 'txn_reconciles', 'transactions', ['txn_id'], ['id']) op.execute('UNLOCK TABLES;')
def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('comments', sa.Column('goodsID', sa.Integer(), nullable=True)) op.alter_column('comments', 'commentatorID', existing_type=mysql.INTEGER(display_width=11), nullable=True) op.drop_constraint('comments_ibfk_2', 'comments', type_='foreignkey') op.create_foreign_key(None, 'comments', 'goods', ['goodsID'], ['goodID']) op.drop_column('comments', 'goodID') op.add_column('goods', sa.Column('address', sa.String(length=128), nullable=False)) op.add_column('goods', sa.Column('poster', sa.String(length=128), nullable=False)) op.add_column('goods', sa.Column('times', sa.Integer(), nullable=True)) op.alter_column('orders', 'createDate', existing_type=mysql.DATETIME(), nullable=False) ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.alter_column('orders', 'createDate', existing_type=mysql.DATETIME(), nullable=True) op.drop_column('goods', 'times') op.drop_column('goods', 'poster') op.drop_column('goods', 'address') op.add_column('comments', sa.Column('goodID', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False)) op.drop_constraint(None, 'comments', type_='foreignkey') op.create_foreign_key('comments_ibfk_2', 'comments', 'goods', ['goodID'], ['goodID']) op.alter_column('comments', 'commentatorID', existing_type=mysql.INTEGER(display_width=11), nullable=False) op.drop_column('comments', 'goodsID') ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('nuccore', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('nuccore_uid', mysql.VARCHAR(length=50), nullable=True), sa.Column('nuccore_link', mysql.TEXT(), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_default_charset=u'utf8', mysql_engine=u'InnoDB' ) op.create_table('dataset_to_nuccore', sa.Column('dataset_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.Column('nuccore_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['dataset_id'], [u'dataset.id'], name=u'dataset_to_nuccore_ibfk_1'), sa.ForeignKeyConstraint(['nuccore_id'], [u'nuccore.id'], name=u'dataset_to_nuccore_ibfk_2'), mysql_default_charset=u'utf8', mysql_engine=u'InnoDB' ) # ### end Alembic commands ###
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('name', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=64), nullable=True), sa.PrimaryKeyConstraint('id'), mysql_collate=u'utf8_unicode_ci', mysql_default_charset=u'utf8', mysql_engine=u'InnoDB' ) op.create_table('users', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('username', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=64), nullable=True), sa.Column('role_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.Column('email', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=64), nullable=True), sa.Column('password_hash', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=128), nullable=True), sa.Column('confirmed', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['role_id'], [u'roles.id'], name=u'users_ibfk_1'), sa.PrimaryKeyConstraint('id'), mysql_collate=u'utf8_unicode_ci', mysql_default_charset=u'utf8', mysql_engine=u'InnoDB' ) op.drop_table('context_show') ### end Alembic commands ###
def downgrade_rdr(): # ### commands auto generated by Alembic - please adjust! ### op.add_column(u'site', sa.Column('consortium_name', mysql.VARCHAR(length=255), nullable=False)) op.drop_constraint(None, 'site', type_='foreignkey') op.alter_column(u'site', 'hpo_id', existing_type=mysql.INTEGER(display_width=11), nullable=False) op.drop_column(u'site', 'zip_code') op.drop_column(u'site', 'state') op.drop_column(u'site', 'site_status') op.drop_column(u'site', 'physical_location_name') op.drop_column(u'site', 'phone_number') op.drop_column(u'site', 'organization_id') op.drop_column(u'site', 'notes') op.drop_column(u'site', 'longitude') op.drop_column(u'site', 'link') op.drop_column(u'site', 'launch_date') op.drop_column(u'site', 'latitude') op.drop_column(u'site', 'directions') op.drop_column(u'site', 'city') op.drop_column(u'site', 'admin_emails') op.drop_column(u'site', 'address_2') op.drop_column(u'site', 'address_1') op.drop_table('organization') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('user_tag', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False)) op.add_column('likes', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False)) op.add_column('custom_tag', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False)) # ### end Alembic commands ###
def unsigned_t(): from sqlalchemy.dialects.mysql import INTEGER id = Column(INTEGER(unsigned = True), primary_key = True) #?????python???
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('Products', sa.Column('maker', mysql.CHAR(collation=u'utf8_unicode_ci', length=2), nullable=True), sa.Column('model', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.Column('tyle', mysql.VARCHAR(collation=u'utf8_unicode_ci', length=10), nullable=True), mysql_collate=u'utf8_unicode_ci', mysql_default_charset=u'utf8', mysql_engine=u'InnoDB' ) op.drop_index(op.f('ix_users_username'), table_name='users') op.drop_index(op.f('ix_users_email'), table_name='users') op.drop_table('users') op.drop_table('roles') ### end Alembic commands ###
def upgrade(): # use batch_alter_table to support SQLite workaround with op.batch_alter_table("task_instance") as batch_op: batch_op.alter_column('duration', existing_type=mysql.INTEGER(display_width=11), type_=sa.Float(), existing_nullable=True)
def downgrade(): # When making changes to a column that has a foreign key, we need to drop # and then re-add the constraint op.execute('LOCK TABLES txn_reconciles WRITE, transactions WRITE;') op.drop_constraint('fk_txn_reconciles_txn_id_transactions', 'txn_reconciles', type_='foreignkey') op.alter_column( 'txn_reconciles', 'txn_id', existing_type=mysql.INTEGER(display_width=11), nullable=True ) op.create_foreign_key('fk_txn_reconciles_txn_id_transactions', 'txn_reconciles', 'transactions', ['txn_id'], ['id']) op.execute('UNLOCK TABLES;')
def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column('goods', sa.Column('contact', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False)) op.drop_column('goods', 'contact_wechat') op.drop_column('goods', 'contact_tel') op.drop_column('goods', 'contact_qq') ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column(u'nuccore', sa.Column('dataset_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True)) op.create_foreign_key(u'nuccore_ibfk_1', 'nuccore', 'dataset', ['dataset_id'], ['id']) op.drop_table('dataset_to_nuccore') # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('dataset_to_discovery', sa.Column('dataset_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.Column('discovery_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['dataset_id'], [u'dataset.id'], name=u'dataset_to_discovery_ibfk_1'), sa.ForeignKeyConstraint(['discovery_id'], [u'discovery.id'], name=u'dataset_to_discovery_ibfk_2'), mysql_default_charset=u'utf8', mysql_engine=u'InnoDB' ) # ### end Alembic commands ###
def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('users', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('username', mysql.VARCHAR(length=100), nullable=False), sa.Column('password_hash', mysql.TEXT(), nullable=False), sa.Column('email', mysql.VARCHAR(length=200), nullable=False), sa.Column('gender', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('desc', mysql.TEXT(), nullable=False), sa.Column('credit', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('role', mysql.VARCHAR(length=20), nullable=False), sa.Column('status', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('created_time', mysql.DATETIME(), nullable=False), sa.Column('updated_time', mysql.DATETIME(), nullable=False), sa.PrimaryKeyConstraint('id'), mysql_default_charset='utf8', mysql_engine='InnoDB' ) op.create_table('posts', sa.Column('id', mysql.INTEGER(display_width=11), nullable=False), sa.Column('user_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True), sa.Column('title', mysql.VARCHAR(length=100), nullable=False), sa.Column('content', mysql.TEXT(), nullable=False), sa.Column('views', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('status', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False), sa.Column('created_time', mysql.DATETIME(), nullable=False), sa.Column('updated_time', mysql.DATETIME(), nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='posts_ibfk_1'), sa.PrimaryKeyConstraint('id'), mysql_default_charset='utf8', mysql_engine='InnoDB' ) # ### end Alembic commands ###
def upgrade_rdr(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('organization', sa.Column('organization_id', sa.Integer(), nullable=False), sa.Column('external_id', sa.String(length=80), nullable=False), sa.Column('display_name', sa.String(length=255), nullable=False), sa.Column('hpo_id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['hpo_id'], ['hpo.hpo_id'], ), sa.PrimaryKeyConstraint('organization_id') ) op.add_column(u'site', sa.Column('address_1', sa.String(length=1024), nullable=True)) op.add_column(u'site', sa.Column('address_2', sa.String(length=1024), nullable=True)) op.add_column(u'site', sa.Column('admin_emails', sa.String(length=4096), nullable=True)) op.add_column(u'site', sa.Column('city', sa.String(length=255), nullable=True)) op.add_column(u'site', sa.Column('directions', sa.String(length=1024), nullable=True)) op.add_column(u'site', sa.Column('latitude', sa.Float(), nullable=True)) op.add_column(u'site', sa.Column('launch_date', sa.Date(), nullable=True)) op.add_column(u'site', sa.Column('link', sa.String(length=255), nullable=True)) op.add_column(u'site', sa.Column('longitude', sa.Float(), nullable=True)) op.add_column(u'site', sa.Column('notes', sa.String(length=1024), nullable=True)) op.add_column(u'site', sa.Column('organization_id', sa.Integer(), nullable=True)) op.add_column(u'site', sa.Column('phone_number', sa.String(length=80), nullable=True)) op.add_column(u'site', sa.Column('physical_location_name', sa.String(length=1024), nullable=True)) op.add_column(u'site', sa.Column('site_status', model.utils.Enum(SiteStatus), nullable=True)) op.add_column(u'site', sa.Column('state', sa.String(length=2), nullable=True)) op.add_column(u'site', sa.Column('zip_code', sa.String(length=10), nullable=True)) op.alter_column(u'site', 'hpo_id', existing_type=mysql.INTEGER(display_width=11), nullable=True) op.create_foreign_key(None, 'site', 'organization', ['organization_id'], ['organization_id']) op.drop_column(u'site', 'consortium_name') # ### end Alembic commands ###