<commit_before>from __future__ import with_statement

from django.core.management.base import BaseCommand  # , CommandError

from django.apps import apps
from django.db import connection
from constance import config
import shutil


class Command(BaseCommand):
    help = "Fixes SQLite databases that have been migrated from Django 1.x to Django 2.0+"

    def fix_sqlite_for_django_2(self):
        if connection.disable_constraint_checking():
            constraints_disabled = "Disabled"
        else:
            constraints_disabled = "NOT Disabled"<commit_msg>Explicitly reopen database connection if closed This is an issue for the way that we're triggering an automatic call to fix_sqlite_for_django_2 from manage.py<commit_after>from __future__ import with_statement

from django.core.management.base import BaseCommand  # , CommandError

from django.apps import apps
from django.db import connection
from constance import config
import shutil


class Command(BaseCommand):
    help = "Fixes SQLite databases that have been migrated from Django 1.x to Django 2.0+"

    def fix_sqlite_for_django_2(self):

        try:
            constraint_check = connection.disable_constraint_checking()
        except:
            connection.connection = connection.connect()
            constraint_check = connection.disable_constraint_checking()

        if constraint_check:
            constraints_disabled = "Disabled"
        else:
            constraints_disabled = "NOT Disabled"
{'fraction_non_alphanumeric': 0.05394470667565745, 'fraction_numerical': 0.006068779501011463, 'mean_word_length': 3.608695652173913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '669875', 'n_tokens_mistral': 389, 'n_tokens_neox': 368, 'n_words': 127}