本文整理汇总了Python中sqlalchemy.BINARY属性的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.BINARY属性的具体用法?Python sqlalchemy.BINARY怎么用?Python sqlalchemy.BINARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sqlalchemy
的用法示例。
在下文中一共展示了sqlalchemy.BINARY属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def upgrade():
op.create_table(
'eventparticipant',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('public_id', sa.BINARY(length=16), nullable=False),
sa.Column('event_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('_raw_address', sa.String(length=191), nullable=True),
sa.Column('_canonicalized_address', sa.String(length=191),
nullable=True),
sa.Column('status', sa.Enum('yes', 'no', 'maybe', 'awaiting'),
default='awaiting', nullable=False),
sa.Column('notes', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.Column('deleted_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['event_id'], ['event.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('_raw_address', 'event_id', name='uid'))
示例2: test_reflect_select
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def test_reflect_select(table, table_using_test_dataset):
for table in [table, table_using_test_dataset]:
assert len(table.c) == 18
assert isinstance(table.c.integer, Column)
assert isinstance(table.c.integer.type, types.Integer)
assert isinstance(table.c.timestamp.type, types.TIMESTAMP)
assert isinstance(table.c.string.type, types.String)
assert isinstance(table.c.float.type, types.Float)
assert isinstance(table.c.boolean.type, types.Boolean)
assert isinstance(table.c.date.type, types.DATE)
assert isinstance(table.c.datetime.type, types.DATETIME)
assert isinstance(table.c.time.type, types.TIME)
assert isinstance(table.c.bytes.type, types.BINARY)
assert isinstance(table.c['record.age'].type, types.Integer)
assert isinstance(table.c['record.name'].type, types.String)
assert isinstance(table.c['nested_record.record.age'].type, types.Integer)
assert isinstance(table.c['nested_record.record.name'].type, types.String)
assert isinstance(table.c.array.type, types.ARRAY)
rows = table.select().execute().fetchall()
assert len(rows) == 1000
示例3: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('nyaa_trackerapi',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('info_hash', sa.BINARY(length=20), nullable=False),
sa.Column('method', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('sukebei_trackerapi',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('info_hash', sa.BINARY(length=20), nullable=False),
sa.Column('method', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
示例4: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def upgrade():
shard_id = int(context.config.get_main_option('shard_id'))
namespace_id_type = sa.Integer() if shard_id == 0 else sa.BigInteger()
op.create_table('accounttransaction',
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.BigInteger(), nullable=False),
sa.Column('public_id', sa.BINARY(length=16), nullable=False),
sa.Column('namespace_id', namespace_id_type, nullable=True),
sa.Column('object_type', sa.String(20), nullable=False),
sa.Column('record_id', sa.BigInteger(), nullable=False),
sa.Column('object_public_id', sa.String(191), nullable=False),
sa.Column('command', sa.Enum('insert', 'update', 'delete'),
nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.ForeignKeyConstraint(['namespace_id'],
[u'namespace.id'],)
)
op.create_index('ix_accounttransaction_created_at',
'accounttransaction', ['created_at'], unique=False)
op.create_index('ix_accounttransaction_updated_at',
'accounttransaction', ['updated_at'], unique=False)
op.create_index('ix_accounttransaction_deleted_at',
'accounttransaction', ['deleted_at'], unique=False)
op.create_index('ix_accounttransaction_table_name',
'accounttransaction', ['object_type'], unique=False)
op.create_index('ix_accounttransaction_command',
'accounttransaction', ['command'], unique=False)
op.create_index('ix_accounttransaction_object_type_record_id',
'accounttransaction', ['object_type', 'record_id'], unique=False)
op.create_index('ix_accounttransaction_namespace_id_created_at',
'accounttransaction', ['namespace_id', 'created_at'], unique=False)
conn = op.get_bind()
increment = (shard_id << 48) + 1
conn.execute('ALTER TABLE accounttransaction AUTO_INCREMENT={}'.format(increment))
示例5: downgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def downgrade():
op.add_column('spoolmessage', sa.Column(u'replyto_thread_id',
mysql.INTEGER(display_width=11),
nullable=True))
op.add_column('spoolmessage', sa.Column(u'draft_copied_from',
mysql.INTEGER(display_width=11),
nullable=True))
op.drop_column('spoolmessage', 'is_reply')
op.create_table(
u'draftthread',
sa.Column(u'created_at', mysql.DATETIME(), nullable=False),
sa.Column(u'updated_at', mysql.DATETIME(), nullable=False),
sa.Column(u'deleted_at', mysql.DATETIME(), nullable=True),
sa.Column(u'public_id', sa.BINARY(length=16), nullable=False),
sa.Column(u'id', mysql.INTEGER(display_width=11), nullable=False),
sa.Column(u'master_public_id', sa.BINARY(length=16), nullable=False),
sa.Column(u'thread_id', mysql.INTEGER(display_width=11),
autoincrement=False, nullable=False),
sa.Column(u'message_id', mysql.INTEGER(display_width=11),
autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['message_id'], [u'message.id'],
name=u'draftthread_ibfk_2'),
sa.ForeignKeyConstraint(['thread_id'], [u'thread.id'],
name=u'draftthread_ibfk_1'),
sa.PrimaryKeyConstraint(u'id'),
mysql_default_charset=u'utf8mb4',
mysql_engine=u'InnoDB'
)
示例6: downgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def downgrade():
op.drop_column('message', 'version')
op.add_column('message', sa.Column('version', sa.BINARY(), nullable=True))
op.drop_column('thread', 'version')
示例7: test_create_table
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def test_create_table(engine):
meta = MetaData()
table = Table(
'test_pybigquery.test_table_create', meta,
Column('integer_c', sqlalchemy.Integer, doc="column description"),
Column('float_c', sqlalchemy.Float),
Column('decimal_c', sqlalchemy.DECIMAL),
Column('string_c', sqlalchemy.String),
Column('text_c', sqlalchemy.Text),
Column('boolean_c', sqlalchemy.Boolean),
Column('timestamp_c', sqlalchemy.TIMESTAMP),
Column('datetime_c', sqlalchemy.DATETIME),
Column('date_c', sqlalchemy.DATE),
Column('time_c', sqlalchemy.TIME),
Column('binary_c', sqlalchemy.BINARY),
bigquery_description="test table description",
bigquery_friendly_name="test table name"
)
meta.create_all(engine)
meta.drop_all(engine)
# Test creating tables with declarative_base
Base = declarative_base()
class TableTest(Base):
__tablename__ = 'test_pybigquery.test_table_create2'
integer_c = Column(sqlalchemy.Integer, primary_key=True)
float_c = Column(sqlalchemy.Float)
Base.metadata.create_all(engine)
Base.metadata.drop_all(engine)
示例8: upgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def upgrade():
from inbox.sqlalchemy_ext.util import JSON
shard_id = int(context.get_x_argument(as_dictionary=True).get('shard_id'))
namespace_id_type = sa.Integer() if shard_id == 0 else sa.BigInteger()
op.create_table(
'metadata',
sa.Column('public_id', sa.BINARY(length=16), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=False),
sa.Column('deleted_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.BigInteger(), nullable=False),
sa.Column('app_id', sa.Integer(), nullable=True),
sa.Column('app_client_id', sa.BINARY(length=16), nullable=False),
sa.Column('app_type', sa.String(length=20), nullable=False),
sa.Column('namespace_id', namespace_id_type, nullable=False),
sa.Column('object_public_id', sa.String(length=191), nullable=False),
sa.Column('object_type', sa.String(length=20), nullable=False),
sa.Column('object_id', sa.BigInteger(), nullable=False),
sa.Column('value', JSON(), nullable=True),
sa.Column('version', sa.Integer(), server_default='0', nullable=True),
sa.ForeignKeyConstraint(['namespace_id'], [u'namespace.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_metadata_created_at'), 'metadata',
['created_at'], unique=False)
op.create_index(op.f('ix_metadata_deleted_at'), 'metadata',
['deleted_at'], unique=False)
op.create_index(op.f('ix_metadata_object_id'), 'metadata',
['object_id'], unique=False)
op.create_index(op.f('ix_metadata_object_public_id'), 'metadata',
['object_public_id'], unique=False)
op.create_index(op.f('ix_metadata_public_id'), 'metadata',
['public_id'], unique=False)
op.create_index(op.f('ix_metadata_updated_at'), 'metadata',
['updated_at'], unique=False)
op.create_index('ix_obj_public_id_app_id', 'metadata',
['object_public_id', 'app_id'], unique=True)
conn = op.get_bind()
increment = (shard_id << 48) + 1
conn.execute('ALTER TABLE metadata AUTO_INCREMENT={}'.format(increment))
示例9: downgrade
# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import BINARY [as 别名]
def downgrade():
op.create_table(
'lens',
sa.Column('public_id', sa.BINARY(length=16), nullable=False),
sa.Column('created_at', mysql.DATETIME(), nullable=False),
sa.Column('updated_at', mysql.DATETIME(), nullable=False),
sa.Column('deleted_at', mysql.DATETIME(), nullable=True),
sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
sa.Column('namespace_id', mysql.INTEGER(display_width=11),
autoincrement=False, nullable=False),
sa.Column('subject', mysql.VARCHAR(length=255), nullable=True),
sa.Column('thread_public_id', sa.BINARY(length=16), nullable=True),
sa.Column('started_before', mysql.DATETIME(), nullable=True),
sa.Column('started_after', mysql.DATETIME(), nullable=True),
sa.Column('last_message_before', mysql.DATETIME(), nullable=True),
sa.Column('last_message_after', mysql.DATETIME(), nullable=True),
sa.Column('any_email', mysql.VARCHAR(length=255), nullable=True),
sa.Column('to_addr', mysql.VARCHAR(length=255), nullable=True),
sa.Column('from_addr', mysql.VARCHAR(length=255), nullable=True),
sa.Column('cc_addr', mysql.VARCHAR(length=255), nullable=True),
sa.Column('bcc_addr', mysql.VARCHAR(length=255), nullable=True),
sa.Column('filename', mysql.VARCHAR(length=255), nullable=True),
sa.Column('tag', mysql.VARCHAR(length=255), nullable=True),
sa.ForeignKeyConstraint(['namespace_id'], [u'namespace.id'],
name=u'lens_ibfk_1', ondelete=u'CASCADE'),
sa.PrimaryKeyConstraint('id'),
mysql_default_charset=u'utf8mb4',
mysql_engine=u'InnoDB'
)
op.create_table(
'webhook',
sa.Column('public_id', sa.BINARY(length=16), nullable=False),
sa.Column('created_at', mysql.DATETIME(), nullable=False),
sa.Column('updated_at', mysql.DATETIME(), nullable=False),
sa.Column('deleted_at', mysql.DATETIME(), nullable=True),
sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
sa.Column('namespace_id', mysql.INTEGER(display_width=11),
autoincrement=False, nullable=False),
sa.Column('lens_id', mysql.INTEGER(display_width=11),
autoincrement=False, nullable=False),
sa.Column('callback_url', mysql.TEXT(), nullable=False),
sa.Column('failure_notify_url', mysql.TEXT(), nullable=True),
sa.Column('include_body', mysql.TINYINT(display_width=1),
autoincrement=False, nullable=False),
sa.Column('max_retries', mysql.INTEGER(display_width=11),
server_default='3', autoincrement=False, nullable=False),
sa.Column('retry_interval', mysql.INTEGER(display_width=11),
server_default='60', autoincrement=False, nullable=False),
sa.Column('active', mysql.TINYINT(display_width=1), server_default='1',
autoincrement=False, nullable=False),
sa.Column('min_processed_id', mysql.INTEGER(display_width=11),
server_default='0', autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['lens_id'], [u'lens.id'],
name=u'webhook_ibfk_2', ondelete=u'CASCADE'),
sa.ForeignKeyConstraint(['namespace_id'], [u'namespace.id'],
name=u'webhook_ibfk_1', ondelete=u'CASCADE'),
sa.PrimaryKeyConstraint('id'),
mysql_default_charset=u'utf8mb4',
mysql_engine=u'InnoDB'
)