def store_tenant(self, clone_schema_from, **fields):
        connection.set_schema_to_public()
        cursor = connection.cursor()

        try:
            tenant = get_tenant_model()(**fields)
            tenant.auto_create_schema = False
            tenant.save()

            clone_schema = CloneSchema(cursor)
            clone_schema.clone(clone_schema_from, tenant.schema_name)
            return tenant
        except exceptions.ValidationError as e:
            self.stderr.write("Error: %s" % '; '.join(e.messages))
            return None
        except IntegrityError:
            return None
dataset/ETHPy150Open tomturner/django-tenants/django_tenants/management/commands/clone_tenant.py/Command.store_tenant/original