def clone_schema(self, base_schema_name, new_schema_name):
        """
        Creates a new schema `new_schema_name` as a clone of an existing schema
        `old_schema_name`.
        """
        connection.set_schema_to_public()
        cursor = connection.cursor()

        # check if the clone_schema function already exists in the db
        try:
            cursor.execute("SELECT 'clone_schema'::regproc")
        except ProgrammingError:
            self._create_clone_schema_function()
            transaction.commit()

        sql = 'SELECT clone_schema(%(base_schema)s, %(new_schema)s, TRUE)'
        cursor.execute(
            sql,
            {'base_schema': base_schema_name, 'new_schema': new_schema_name}
        )
        cursor.close()
def clone_schema ( self , base_schema_name , new_schema_name ) : connection . set_schema_to_public ( ) cursor = connection . cursor ( ) try : cursor . execute ( "SELECT 'clone_schema'::regproc" ) except ProgrammingError : self . _create_clone_schema_function ( ) transaction . commit ( ) sql = 'SELECT clone_schema(%(base_schema)s, %(new_schema)s, TRUE)' cursor . execute ( sql , { 'base_schema' : base_schema_name , 'new_schema' : new_schema_name } ) cursor . close ( )
Creates a new schema `new_schema_name` as a clone of an existing schema
        `old_schema_name`.