當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。