<commit_before>from django.core.management import call_command
from django.core.management import BaseCommand

from django.db import connection
from StringIO import StringIO


class Command(BaseCommand):
    def handle(self, *args, **kwargs):
        # 'call' manage.py flush and capture its outputted sql
        command_output = StringIO()
        call_command("sqlflush", stdout=command_output)

        command_output.seek(0)
        flush_sql = command_output.read().strip()
        print flush_sql
        flush_sql = """DELETE FROM "auth_permission";
DELETE FROM "auth_group";
DELETE FROM "django_site";
DELETE FROM "accounts_user_user_permissions";
DELETE FROM "django_content_type";
DELETE FROM "django_session";
DELETE FROM "accounts_user";
DELETE FROM "django_openid_auth_useropenid";
DELETE FROM "django_admin_log";
DELETE FROM "auth_group_permissions";
DELETE FROM "django_openid_auth_nonce";
DELETE FROM "news";
DELETE FROM "thumbnail_kvstore";
DELETE FROM "django_select2_keymap";
DELETE FROM "django_openid_auth_association";
DELETE FROM "south_migrationhistory";
DELETE FROM "accounts_user_groups";
DELETE FROM "common_upload";""".split('\n')

        # execute the sql
        # from: https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly
        cursor = connection.cursor()
        for statement in flush_sql:
            print statement
            print type(statement)
            cursor.execute(statement)

        print "db has been reset"<commit_msg>Fix syntax errors in emptydb script<commit_after>from django.core.management import call_command
from django.core.management import BaseCommand

from django.db import connection
from StringIO import StringIO


class Command(BaseCommand):
    def handle(self, *args, **kwargs):
        # 'call' manage.py flush and capture its outputted sql
        command_output = StringIO()
        call_command("sqlflush", stdout=command_output)

        command_output.seek(0)
        flush_sql = command_output.read().strip()

        # execute the sql
        # from: https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly
        cursor = connection.cursor()
        for statement in flush_sql:
            print(statement)
            print(type(statement))
            cursor.execute(statement)
        print("db has been reset")
{'fraction_non_alphanumeric': 0.09218351741716228, 'fraction_numerical': 0.001274426508071368, 'mean_word_length': 3.6726190476190474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7643356', 'n_tokens_mistral': 659, 'n_tokens_neox': 647, 'n_words': 174}