当前位置: 首页>>代码示例>>Python>>正文


Python sqlalchemy.Binary方法代码示例

本文整理汇总了Python中sqlalchemy.Binary方法的典型用法代码示例。如果您正苦于以下问题:Python sqlalchemy.Binary方法的具体用法?Python sqlalchemy.Binary怎么用?Python sqlalchemy.Binary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy的用法示例。


在下文中一共展示了sqlalchemy.Binary方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _cast

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def _cast(t, expr):
    arg, typ = expr.op().args

    sa_arg = t.translate(arg)
    sa_type = t.get_sqla_type(typ)

    # specialize going from an integer type to a timestamp
    if isinstance(arg.type(), dt.Integer) and isinstance(sa_type, sa.DateTime):
        return sa.func.timezone('UTC', sa.func.to_timestamp(sa_arg))

    if arg.type().equals(dt.binary) and typ.equals(dt.string):
        return sa.func.encode(sa_arg, 'escape')

    if typ.equals(dt.binary):
        #  decode yields a column of memoryview which is annoying to deal with
        # in pandas. CAST(expr AS BYTEA) is correct and returns byte strings.
        return sa.cast(sa_arg, sa.Binary())

    return sa.cast(sa_arg, sa_type) 
开发者ID:ibis-project,项目名称:ibis,代码行数:21,代码来源:compiler.py

示例2: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def upgrade():
	op.create_table(
		'storage_data',
		sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
		sqlalchemy.Column('created', sqlalchemy.DateTime),
		sqlalchemy.Column('namespace', sqlalchemy.String),
		sqlalchemy.Column('key', sqlalchemy.String, nullable=False),
		sqlalchemy.Column('value', sqlalchemy.Binary)
	)

	db_manager.Session.remove()
	db_manager.Session.configure(bind=op.get_bind())
	session = db_manager.Session()
	db_manager.set_meta_data('schema_version', 7, session=session)
	session.commit() 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:17,代码来源:b76eab0a059_schema_v7.py

示例3: sa_binary

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def sa_binary(_, satype, nullable=True):
    return dt.Binary(nullable=nullable) 
开发者ID:ibis-project,项目名称:ibis,代码行数:4,代码来源:alchemy.py

示例4: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('_password', sa.Binary(), nullable=False),
    sa.Column('authenticated', sa.Boolean(), nullable=True),
    sa.Column('email_confirmation_sent_on', sa.DateTime(), nullable=True),
    sa.Column('email_confirmed', sa.Boolean(), nullable=True),
    sa.Column('email_confirmed_on', sa.DateTime(), nullable=True),
    sa.Column('registered_on', sa.DateTime(), nullable=True),
    sa.Column('last_logged_in', sa.DateTime(), nullable=True),
    sa.Column('current_logged_in', sa.DateTime(), nullable=True),
    sa.Column('role', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('items',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('notes', sa.String(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ### 
开发者ID:jelmerdejong,项目名称:flask-app-blueprint,代码行数:28,代码来源:783d98209305_.py

示例5: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('registration_ip', sa.Binary(), nullable=True))
    # ### end Alembic commands ### 
开发者ID:nyaadevs,项目名称:nyaa,代码行数:6,代码来源:f703f911d4ae_add_registration_ip.py

示例6: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def upgrade():
    op.create_table('bans',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('created_time', sa.DateTime(), nullable=True),
    sa.Column('admin_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('user_ip', sa.Binary(length=16), nullable=True),
    sa.Column('reason', sa.String(length=2048), nullable=False),
    sa.ForeignKeyConstraint(['admin_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    )
    op.create_index('user_ip_16', 'bans', ['user_ip'], unique=True, mysql_length=16)
    op.create_index('user_ip_4', 'bans', ['user_ip'], unique=True, mysql_length=4) 
开发者ID:nyaadevs,项目名称:nyaa,代码行数:16,代码来源:500117641608_add_bans.py

示例7: upgrade

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def upgrade():

    for prefix in TABLE_PREFIXES:
        op.add_column(prefix + '_torrents', sa.Column('uploader_ip', sa.Binary(), nullable=True))
        # ### end Alembic commands ### 
开发者ID:nyaadevs,项目名称:nyaa,代码行数:7,代码来源:3001f79b7722_add_torrents.uploader_ip.py

示例8: create_md_model

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def create_md_model(metadata=None):
    return Table('metric_dimension', metadata,
                 Column('dimension_set_id', Binary),
                 Column('name', String(255)),
                 Column('value', String(255))) 
开发者ID:openstack,项目名称:monasca-api,代码行数:7,代码来源:models.py

示例9: create_mde_model

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def create_mde_model(metadata=None):
    return Table('metric_definition', metadata,
                 Column('id', Binary),
                 Column('name', String(255)),
                 Column('tenant_id', String(255)),
                 Column('region', String(255))) 
开发者ID:openstack,项目名称:monasca-api,代码行数:8,代码来源:models.py

示例10: create_mdd_model

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def create_mdd_model(metadata=None):
    return Table('metric_definition_dimensions', metadata,
                 Column('id', Binary),
                 Column('metric_definition_id', Binary),
                 Column('metric_dimension_set_id', Binary)) 
开发者ID:openstack,项目名称:monasca-api,代码行数:7,代码来源:models.py

示例11: create_am_model

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy import Binary [as 别名]
def create_am_model(metadata=None):
    return Table('alarm_metric', metadata,
                 Column('alarm_id', String(36)),
                 Column('metric_definition_dimensions_id', Binary)) 
开发者ID:openstack,项目名称:monasca-api,代码行数:6,代码来源:models.py

示例12: BinaryArray

# 需要导入模块: import sqlalchemy [as 别名]
# 或者: from sqlalchemy 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") 
开发者ID:ChrisCummins,项目名称:clgen,代码行数:12,代码来源:sqlutil.py


注:本文中的sqlalchemy.Binary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。