打开app下的__init__.py 文件,输入如下:
from django.db.backends.signals import connection_created
def ini_pragmas(sender, connection, **kwargs):
if connection.vendor == 'sqlite':
cursor = connection.cursor()
cursor.execute('PRAGMA synchronous = NORMAL;')
cursor.execute('PRAGMA cache_size = 52428800;')
cursor.execute('PRAGMA temp_store = MEMORY;')
cursor.execute('PRAGMA mmap_size = 52428800;')
cursor.execute('PRAGMA optimize;')
connection_created.connect(ini_pragmas)