После долгих копаний вы можете использовать прагму таким образом:
from django.core.management.base import BaseCommand
from django.db import connection
class Command(BaseCommand):
help = 'Checkpoint the database, updating <db>.sqlite3 and removing <db>.sqlite3-wal and <db>.sqlite3-shm files'
def add_arguments(self, parser):
parser.add_argument('-cm', '--checkpoint_mode', default='TRUNCATE',
choices=['PASSIVE', 'FULL', 'RESTART', 'TRUNCATE'],
help='Checkpoint mode - See sqlite3 documentation for options (default is TRUNCATE)')
def handle(self, *args, **options):
with connection.cursor() as cursor:
cursor.execute(f"PRAGMA wal_checkpoint({options['checkpoint_mode']});")
result = cursor.fetchone()
print(f'{result}')