@@ -0,0 +1,1500 @@
+from django.core.management.base import BaseCommand%0Afrom cloudant.client import Cloudant%0A%0ACOUCH2_HOST = %22localhost%22%0ACOUCH2_PORT = 5984%0A%0ACOUCH3_HOST = %22localhost%22%0ACOUCH3_PORT = 5985%0A%0A%0Adef sync_dbs(source_db_obj, destination_db_obj):%0A    for doc in source_db_obj:%0A        doc_obj = destination_db_obj.create_document(doc)%0A        if not doc_obj.exists():%0A            print(f'Unable to sync $%7Bdoc_obj._id%7D in $%7Bdestination_db_obj.database_name%7D')%0A%0A%0Aclass Command(BaseCommand):%0A    help = %22%22%22Script to copy local couchdb2 docs to couchdb3.%0A    It will iterate through all dbs sequentially and populate in couchdb3%22%22%22%0A%0A    def handle(self, **options):%0A        couch2_client = Cloudant('', '', admin_party=True, url=f'http://%7BCOUCH2_HOST%7D:%7BCOUCH2_PORT%7D', connect=True)%0A        couch3_client = Cloudant('', '', admin_party=True, url=f'http://%7BCOUCH3_HOST%7D:%7BCOUCH3_PORT%7D', connect=True)%0A%0A        source = couch2_client%0A        destination = couch3_client%0A%0A        old_dbs = source.all_dbs()%0A        db_not_created = %5B%5D%0A%0A        for db_name in old_dbs:%0A            print(f'Copying db %7Bdb_name%7D')%0A            new_db_obj = destination.create_database(db_name)%0A            old_db_obj = source%5Bdb_name%5D%0A            if not new_db_obj.exists():%0A                db_not_created.append(db_name)%0A            else:%0A                sync_dbs(old_db_obj, new_db_obj)%0A        print(%22Clearing out connection objects%22)%0A        source.disconnect()%0A        destination.disconnect()%0A        print(%22Databases sucessfully copied%22)%0A

add script to copy docs to couch 3