Exemplo n.º 1
0
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('step',
                    u'step_number',
                    existing_type=sa.INT(),
                    nullable=False)
    op.alter_column('step',
                    u'next_step_number',
                    existing_type=sa.INT(),
                    nullable=True)
def upgrade():
    op.create_table(
        'gcloud_portqoss',
         sa.Column("port_id",sa.String(36),
                        sa.ForeignKey('ports.id', ondelete="CASCADE"),
                        nullable=False),
         sa.Column("ingress",sa.INT(), nullable=True),
         sa.Column("outgress",sa.INT(), nullable=True),
	 sa.UniqueConstraint('port_id')
    )
def downgrade():
    load_stored_proc(op, ['update_gccrashes.sql'])
    op.execute(""" DROP FUNCTION crash_madu(bigint, numeric, numeric) """)
    op.alter_column(u'gccrashes',
                    u'gc_count_madu',
                    new_column_name=u'is_gc_count',
                    type_=sa.INT())
Exemplo n.º 4
0
def ToAlc(clazz) -> type:
    """ 需要从nn定义的table结构转换成alc的结构 """
    ti = GetTableInfo(clazz)
    if not ti:
        return None

    fullnm = '_arc_' + clazz.__module__ + '_' + clazz.__name__
    fullnm = fullnm.replace('.', '_')
    if fullnm in _alc_cache:
        return _alc_cache[fullnm]

    # 创建一个新类
    defs = {'__tablename__': ti.table}

    # 添加字段定义
    fps = GetFieldInfos(clazz)
    for k in fps:
        fp: FieldOption = fps[k]
        cols = []
        kwcols = {}
        dc = None
        if fp.string:
            if fp.len:
                dc = alc.VARCHAR(fp.len)
            else:
                dc = alc.TEXT()
        elif fp.integer:
            dc = alc.INT()
        elif fp.double or fp.number:
            dc = alc.FLOAT()
        elif fp.boolean:
            dc = mysqltypes.TINYINT(1)
        elif fp.json or fp.array or fp.map:
            dc = alc.JSON()
        elif fp.intfloat:
            dc = alc.FLOAT()
        cols.append(dc)

        if fp.primary:
            kwcols['primary_key'] = True
        if fp.notnull:
            kwcols['nullable'] = False
        if fp.autoinc:
            kwcols['autoincrement'] = True

        defs[k] = alc.Column(*cols, **kwcols)

    clz = type(fullnm, (declarative_base(), ), defs)
    _alc_cache[fullnm] = clz
    return clz
Exemplo n.º 5
0
    def get_int_fld_type(col):
        """
        Determines the sql int type based on the series value range.

        """
        min_val = df[col].min()
        max_val = df[col].max()

        if min_val >= -32767 and max_val <= 32767:
            return sqlalchemy.SMALLINT()
        elif min_val >= -2147483647 and max_val <= 2147483647:
            return sqlalchemy.INT()
        else:
            return sqlalchemy.BIGINT()
Exemplo n.º 6
0
def insert_t02_gta_data_iran():
    df = feather.read_dataframe(path)
    itrpoc_engine = gen_itr_engine(db='itrpoc')
    df.to_sql('t02_gta_data_iran',
              itrpoc_engine,
              if_exists='replace',
              index=False,
              chunksize=10000,
              dtype={
                  'year': sqlalchemy.INT(),
                  'trade': sqlalchemy.VARCHAR(8),
                  'hscode': sqlalchemy.CHAR(6),
                  'reporter': sqlalchemy.VARCHAR(45),
                  'partner': sqlalchemy.VARCHAR(45),
                  'weight': sqlalchemy.BIGINT(),
                  'value': sqlalchemy.BIGINT(),
              })
    itrpoc_engine.dispose()
Exemplo n.º 7
0
def upgrade():
    op.drop_column('jobs', 'output')

    op.add_column('jobs', sa.Column('progress', sa.INT(), nullable=True))
    op.add_column('jobs', sa.Column('error', sa.JSON(), nullable=True))
Exemplo n.º 8
0
           connStr = myFile.readline()
           data_conn = connStr.split(" ",2)
           dbname = data_conn[0].split("=",1)[1]
           username = data_conn[1].split("=",1)[1]
           password = data_conn[2].split("=",1)[1]
           print(connStr,dbname,username,password)
           conn = connect(connStr)
           cur = conn.cursor()
 
           # Create engine for import dataframe
           db_url = 'postgresql://'+username+':'+password+'@localhost:5432/'+dbname
           engine = create_engine(db_url)
           # Import dataframe
       
           Position_Set.to_sql('positionset', engine, if_exists='append',index=False,
             dtype={'id_pos_table': sq.INT(),
              #'description': sq.CHAR(),
              'id_result':sq.INT(),
              'sol_id': sq.INT()
           })
           GNSS_Position.to_sql('gnssposition', engine ,if_exists='append',index=False,
             dtype={'id_pos': sq.INT(),
               'pos_time': sq.INT(),
               'pos_x': sq.FLOAT(),
               'pos_y': sq.FLOAT(),
               'pos_z': sq.FLOAT(),
               'id_pos_table':sq.INT(),
               'sol_id': sq.INT(),
               'flag_pos': sq.INT()
           })
           Tropo_Set.to_sql('troposet', engine, if_exists='append',index=False,
Exemplo n.º 9
0
import sqlalchemy

metadata = sqlalchemy.MetaData()

templates = sqlalchemy.Table(
    'templates', metadata,
    sqlalchemy.Column('name', sqlalchemy.CHAR(length=70), primary_key=True),
    sqlalchemy.Column('activeVersion',
                      sqlalchemy.INT(),
                      server_default=sqlalchemy.text('1')),
    sqlalchemy.Column('t_createdAt',
                      sqlalchemy.TIMESTAMP(),
                      server_default=sqlalchemy.text('NOW()'),
                      nullable=False),
    sqlalchemy.Column('t_updatedAt',
                      sqlalchemy.TIMESTAMP(),
                      server_default=sqlalchemy.text('NOW()'),
                      nullable=False),
    sqlalchemy.Column('t_deletedAt', sqlalchemy.TIMESTAMP()),
    sqlalchemy.Column('t_createdBy',
                      sqlalchemy.CHAR(length=30),
                      nullable=False),
    sqlalchemy.Column('t_updatedBy',
                      sqlalchemy.CHAR(length=30),
                      nullable=False),
    sqlalchemy.Column('t_deletedBy', sqlalchemy.CHAR(length=30)))

versions = sqlalchemy.Table(
    'versions', metadata,
    sqlalchemy.Column('number', sqlalchemy.INT(), primary_key=True),
    sqlalchemy.Column('templateName',