def migrate(dbs): visited_dbs, success_dbs, failed_dbs = [], [], [] for db in dbs: try: dbm = get_db_manager(server=SERVER, database=db) visited_dbs.append(db) sync_views(dbm) subject_short_codes_dict = dict(find_subject_short_code(dbm)) if not subject_short_codes_dict: remove_db_manager(dbm) continue entity_question_codes_dict = dict(find_entity_question_code(dbm)) output.writelines("\nMigration database [%s]" % db) correct_submissions(dbm, subject_short_codes_dict, entity_question_codes_dict) remove_db_manager(dbm) success_dbs.append(db) except Exception as e: failed_dbs.append(db) print e pass output.close() return visited_dbs, success_dbs, failed_dbs
def delete_redundant_language_setting_from_form(): dbs = all_db_names(db_server) for db_name in dbs: try: logger.info(db_name) print db_name manager = get_db_manager(server=db_server, database=db_name) delete_language_setting_for_form_models(manager) remove_db_manager(manager) except Exception as e: print("******************************************", db_name) print e print("***************************************************")
def find_organization(): dbs = all_db_names(db_server) for db in dbs: print db manager = get_db_manager(server=db_server, database=db,credentials=settings.COUCHDBMAIN_CREDENTIALS) database_query = manager.database.query(map_project_id_to_organization) if database_query: organization_setting = OrganizationSetting.objects.filter(document_store=db)[0] organization_name = organization_setting.organization.name print ("********************************************") print "Document store: %s" % db print "Organization name: %s" % organization_name break remove_db_manager(manager)