示例#1
0
def init_senseguard_database():
    ssh = SSH(**ssh_config)

    for file in INIT_SQL_FILES:
        if os.path.exists(os.path.join(PATH_OF_INIT_SQL_FILES, file)):
            ssh.scp_local_file(file, PATH_OF_INIT_SQL_FILES, '~/')
            ssh.execute_command(
                f"mysql -h{db_config.get('host')} -P{db_config.get('port')} -u{db_config.get('user')} -p{db_config.get('password')} < {file}"
            )