Exemplo n.º 1
0
def check_env(config):
    """check runtime env"""
    try:
        backup_path = config.get("database", "backup_path")
        if not os.path.exists(backup_path):
            os.makedirs(backup_path)
    except Exception as err:
        shell.err("check_env error %s" % repr(err))
Exemplo n.º 2
0
def check_env(config):
    """check runtime env"""
    try:
        backup_path = config.get('database', 'backup_path')
        if not os.path.exists(backup_path):
            os.makedirs(backup_path)
    except Exception as err:
        shell.err("check_env error %s" % repr(err))
Exemplo n.º 3
0
def execute_sqls(config,sqlstr):
    sh.info('exec sql >> %s'%sqlstr)
    results = []
    with get_engine(config).begin() as conn:
        try:
            results = conn.execute(_sql(sqlstr))
        except Exception as err:
            return sh.err('exec sql error: %s'%str(err))
    sh.info('exec sql done')
    print_result(results)
Exemplo n.º 4
0
def execute_sqls(config, sqlstr):
    sh.info("exec sql >> %s" % sqlstr)
    results = []
    with get_engine(config).begin() as conn:
        try:
            results = conn.execute(_sql(sqlstr))
        except Exception as err:
            return sh.err("exec sql error: %s" % str(err))
    sh.info("exec sql done")
    print_result(results)
Exemplo n.º 5
0
def execute_sqlf(config, sqlfile):
    sh.info('exec sql file >> %s' % sqlfile)
    if not os.path.exists(sqlfile):
        return sh.warn('sqlfile not exists')
    conn = get_engine(config).raw_connection()
    try:
        for line in open(sqlfile):
            sh.info(line)
            conn.execute(line)
    except Exception as err:
        return sh.err('exec sql file error: %s' % str(err))
    finally:
        conn.close()
    sh.info('exec sql file done')
Exemplo n.º 6
0
def execute_sqlf(config, sqlfile):
    sh.info("exec sql file >> %s" % sqlfile)
    if not os.path.exists(sqlfile):
        return sh.warn("sqlfile not exists")
    conn = get_engine(config).raw_connection()
    try:
        for line in open(sqlfile):
            sh.info(line)
            conn.execute(line)
    except Exception as err:
        return sh.err("exec sql file error: %s" % str(err))
    finally:
        conn.close()
    sh.info("exec sql file done")