def copydb(self, sourcedb, destslab, destdbname=None, progresscb=None):
        '''
        Copy an entire database in this slab to a new database in potentially another slab.

        Args:
            sourcedb (LmdbDatabase): which database in this slab to copy rows from
            destslab (LmdbSlab): which slab to copy rows to
            destdbname (str): the name of the database to copy rows to in destslab
            progresscb (Callable[int]):  if not None, this function will be periodically called with the number of rows
                                         completed

        Returns:
            (int): the number of rows copied

        Note:
            If any rows already exist in the target database, this method returns an error.  This means that one cannot
            use destdbname=None unless there are no explicit databases in the destination slab.
        '''
        destdb = destslab.initdb(destdbname, sourcedb.dupsort)

        statdict = destslab.stat(db=destdb)
        if statdict['entries'] > 0:
            raise s_exc.DataAlreadyExists()

        rowcount = 0

        for chunk in s_common.chunks(self.scanByFull(db=sourcedb), COPY_CHUNKSIZE):
            ccount, acount = destslab.putmulti(chunk, dupdata=True, append=True, db=destdb)
            if ccount != len(chunk) or acount != len(chunk):
                raise s_exc.BadCoreStore(mesg='Unexpected number of values written')  # pragma: no cover

            rowcount += len(chunk)
            if progresscb is not None and 0 == (rowcount % PROGRESS_PERIOD):
                progresscb(rowcount)

        return rowcount
def copydb ( self , sourcedb , destslab , destdbname = None , progresscb = None ) : destdb = destslab . initdb ( destdbname , sourcedb . dupsort ) statdict = destslab . stat ( db = destdb ) if statdict [ 'entries' ] > 0 : raise s_exc . DataAlreadyExists ( ) rowcount = 0 for chunk in s_common . chunks ( self . scanByFull ( db = sourcedb ) , COPY_CHUNKSIZE ) : ccount , acount = destslab . putmulti ( chunk , dupdata = True , append = True , db = destdb ) if ccount != len ( chunk ) or acount != len ( chunk ) : raise s_exc . BadCoreStore ( mesg = 'Unexpected number of values written' ) rowcount += len ( chunk ) if progresscb is not None and 0 == ( rowcount % PROGRESS_PERIOD ) : progresscb ( rowcount ) return rowcount
Copy an entire database in this slab to a new database in potentially another slab.

        Args:
            sourcedb (LmdbDatabase): which database in this slab to copy rows from
            destslab (LmdbSlab): which slab to copy rows to
            destdbname (str): the name of the database to copy rows to in destslab
            progresscb (Callable[int]):  if not None, this function will be periodically called with the number of rows
                                         completed

        Returns:
            (int): the number of rows copied

        Note:
            If any rows already exist in the target database, this method returns an error.  This means that one cannot
            use destdbname=None unless there are no explicit databases in the destination slab.