Python sqlalchemy.Binary() Examples
The following are 12
code examples of sqlalchemy.Binary().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy
, or try the search function
.
Example #1
Source File: compiler.py From ibis with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: b76eab0a059_schema_v7.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #3
Source File: alchemy.py From ibis with Apache License 2.0 | 5 votes |
def sa_binary(_, satype, nullable=True): return dt.Binary(nullable=nullable)
Example #4
Source File: 783d98209305_.py From flask-app-blueprint with MIT License | 5 votes |
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 ###
Example #5
Source File: f703f911d4ae_add_registration_ip.py From nyaa with GNU General Public License v3.0 | 5 votes |
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('users', sa.Column('registration_ip', sa.Binary(), nullable=True)) # ### end Alembic commands ###
Example #6
Source File: 500117641608_add_bans.py From nyaa with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: 3001f79b7722_add_torrents.uploader_ip.py From nyaa with GNU General Public License v3.0 | 5 votes |
def upgrade(): for prefix in TABLE_PREFIXES: op.add_column(prefix + '_torrents', sa.Column('uploader_ip', sa.Binary(), nullable=True)) # ### end Alembic commands ###
Example #8
Source File: models.py From monasca-api with Apache License 2.0 | 5 votes |
def create_md_model(metadata=None): return Table('metric_dimension', metadata, Column('dimension_set_id', Binary), Column('name', String(255)), Column('value', String(255)))
Example #9
Source File: models.py From monasca-api with Apache License 2.0 | 5 votes |
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)))
Example #10
Source File: models.py From monasca-api with Apache License 2.0 | 5 votes |
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))
Example #11
Source File: models.py From monasca-api with Apache License 2.0 | 5 votes |
def create_am_model(metadata=None): return Table('alarm_metric', metadata, Column('alarm_id', String(36)), Column('metric_definition_dimensions_id', Binary))
Example #12
Source File: sqlutil.py From clgen with GNU General Public License v3.0 | 5 votes |
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")