本文整理汇总了Python中sqlalchemy.dialects.mysql.BINARY属性的典型用法代码示例。如果您正苦于以下问题:Python mysql.BINARY属性的具体用法?Python mysql.BINARY怎么用?Python mysql.BINARY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sqlalchemy.dialects.mysql
的用法示例。
在下文中一共展示了mysql.BINARY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_dialect_impl
# 需要导入模块: from sqlalchemy.dialects import mysql [as 别名]
# 或者: from sqlalchemy.dialects.mysql import BINARY [as 别名]
def load_dialect_impl(self, dialect):
if dialect.name == 'postgresql':
return dialect.type_descriptor(UUID())
elif dialect.name == 'oracle':
return dialect.type_descriptor(RAW(16))
elif dialect.name == 'mysql':
return dialect.type_descriptor(BINARY(16))
else:
return dialect.type_descriptor(CHAR(32))
示例2: BinaryArray
# 需要导入模块: from sqlalchemy.dialects import mysql [as 别名]
# 或者: from sqlalchemy.dialects.mysql import BINARY [as 别名]
def BinaryArray(length: int):
"""Return a fixed size binary array column type.
Args:
length: The length of the column.
Returns:
A column type.
"""
return sql.Binary(length).with_variant(mysql.BINARY(length), "mysql")
示例3: upgrade
# 需要导入模块: from sqlalchemy.dialects import mysql [as 别名]
# 或者: from sqlalchemy.dialects.mysql import BINARY [as 别名]
def upgrade():
op.create_table(
'webhookparameters',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('public_id', mysql.BINARY(16), nullable=False),
sa.Column('namespace_id', sa.Integer(), nullable=False),
sa.Column('callback_url', sa.Text(), nullable=False),
sa.Column('failure_notify_url', sa.Text(), nullable=True),
sa.Column('to_addr', sa.String(length=255), nullable=True),
sa.Column('from_addr', sa.String(length=255), nullable=True),
sa.Column('cc_addr', sa.String(length=255), nullable=True),
sa.Column('bcc_addr', sa.String(length=255), nullable=True),
sa.Column('email', sa.String(length=255), nullable=True),
sa.Column('subject', sa.String(length=255), nullable=True),
sa.Column('thread', mysql.BINARY(16), nullable=True),
sa.Column('filename', sa.String(length=255), nullable=True),
sa.Column('started_before', sa.DateTime(), nullable=True),
sa.Column('started_after', sa.DateTime(), nullable=True),
sa.Column('last_message_before', sa.DateTime(), nullable=True),
sa.Column('last_message_after', sa.DateTime(), nullable=True),
sa.Column('include_body', sa.Boolean(), nullable=False),
sa.Column('max_retries', sa.Integer(), server_default='3',
nullable=False),
sa.Column('retry_interval', sa.Integer(), server_default='60',
nullable=False),
sa.Column('active', sa.Boolean(),
server_default=sa.sql.expression.true(),
nullable=False),
sa.Column('min_processed_id', sa.Integer(), server_default='0',
nullable=False),
sa.ForeignKeyConstraint(['namespace_id'], ['namespace.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_index('ix_webhookparameters_public_id', 'webhookparameters',
['public_id'], unique=False)
示例4: upgrade
# 需要导入模块: from sqlalchemy.dialects import mysql [as 别名]
# 或者: from sqlalchemy.dialects.mysql import BINARY [as 别名]
def upgrade():
# Create DraftThread table
op.create_table('draftthread',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('master_public_id', mysql.BINARY(16),
nullable=False),
sa.Column('thread_id', sa.Integer()),
sa.ForeignKeyConstraint(['thread_id'],
['thread.id'],
ondelete='CASCADE'),
sa.Column('message_id', sa.Integer()),
sa.ForeignKeyConstraint(['message_id'],
['message.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
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('public_id', mysql.BINARY(16), nullable=False,
index=True),
)
# Add columns to SpoolMessage table
op.add_column('spoolmessage',
sa.Column('parent_draft_id', sa.Integer(), nullable=True))
op.create_foreign_key('spoolmessage_ibfk_3',
'spoolmessage', 'spoolmessage',
['parent_draft_id'], ['id'])
op.add_column('spoolmessage',
sa.Column('draft_copied_from', sa.Integer(), nullable=True))
op.create_foreign_key('spoolmessage_ibfk_4',
'spoolmessage', 'spoolmessage',
['draft_copied_from'], ['id'])
op.add_column('spoolmessage',
sa.Column('replyto_thread_id', sa.Integer(), nullable=True))
op.create_foreign_key('spoolmessage_ibfk_5',
'spoolmessage', 'draftthread',
['replyto_thread_id'], ['id'])
op.add_column('spoolmessage', sa.Column('state', sa.Enum('draft',
'sending', 'sending failed', 'sent'), server_default='draft',
nullable=False))
示例5: upgrade
# 需要导入模块: from sqlalchemy.dialects import mysql [as 别名]
# 或者: from sqlalchemy.dialects.mysql import BINARY [as 别名]
def upgrade():
from inbox.sqlalchemy_ext.util import generate_public_id
from inbox.models.session import session_scope
# These all inherit HasPublicID
from inbox.models import (
Account, Block, Contact, Message, Namespace,
SharedFolder, Thread, User, UserSession, HasPublicID)
classes = [
Account, Block, Contact, Message, Namespace,
SharedFolder, Thread, User, UserSession]
for c in classes:
assert issubclass(c, HasPublicID)
print '[{0}] adding public_id column... '.format(c.__tablename__),
sys.stdout.flush()
op.add_column(c.__tablename__, sa.Column(
'public_id', mysql.BINARY(16), nullable=False))
print 'adding index... ',
op.create_index(
'ix_{0}_public_id'.format(c.__tablename__),
c.__tablename__,
['public_id'],
unique=False)
print 'Done!'
sys.stdout.flush()
print 'Finished adding columns. \nNow generating public_ids'
with session_scope() as db_session:
count = 0
for c in classes:
garbage_collect()
print '[{0}] Loading rows. '.format(c.__name__),
sys.stdout.flush()
print 'Generating public_ids',
sys.stdout.flush()
for r in db_session.query(c).yield_per(chunk_size):
count += 1
r.public_id = generate_public_id()
if not count % chunk_size:
sys.stdout.write('.')
sys.stdout.flush()
db_session.commit()
garbage_collect()
sys.stdout.write(' Saving. '.format(c.__name__)),
# sys.stdout.flush()
sys.stdout.flush()
db_session.commit()
sys.stdout.write('Done!\n')
sys.stdout.flush()
print '\nUpdgraded OK!\n'
示例6: upgrade
# 需要导入模块: from sqlalchemy.dialects import mysql [as 别名]
# 或者: from sqlalchemy.dialects.mysql import BINARY [as 别名]
def upgrade():
op.add_column('transaction',
sa.Column('public_id', mysql.BINARY(16), nullable=True))
op.add_column('transaction',
sa.Column('object_public_id', sa.String(length=191),
nullable=True))
op.create_index('ix_transaction_public_id', 'transaction', ['public_id'],
unique=False)
from inbox.sqlalchemy_ext.util import generate_public_id, b36_to_bin
# TODO(emfree) reflect
from inbox.models.session import session_scope
from inbox.ignition import main_engine
engine = main_engine(pool_size=1, max_overflow=0)
Base = declarative_base()
Base.metadata.reflect(engine)
class Transaction(Base):
__table__ = Base.metadata.tables['transaction']
with session_scope(versioned=False) as db_session:
count = 0
num_transactions, = db_session.query(sa.func.max(Transaction.id)).one()
print 'Adding public ids to {} transactions'.format(num_transactions)
for pointer in range(0, num_transactions + 1, 500):
for entry in db_session.query(Transaction).filter(
Transaction.id >= pointer,
Transaction.id < pointer + 500):
entry.public_id = b36_to_bin(generate_public_id())
count += 1
if not count % 500:
sys.stdout.write('.')
sys.stdout.flush()
db_session.commit()
garbage_collect()
op.alter_column('transaction', 'public_id',
existing_type=mysql.BINARY(16), nullable=False)
op.add_column('transaction', sa.Column('public_snapshot',
sa.Text(length=4194304),
nullable=True))
op.add_column('transaction', sa.Column('private_snapshot',
sa.Text(length=4194304),
nullable=True))
op.drop_column('transaction', u'additional_data')