<commit_before>import sqlite3
import nabber
from dbhandler import db_session, init_db
from models import Incident




def create_db():
    """Creates a sqlite3 database using our models"""
    db_session()
    init_db()
    db_session.remove()

def addto_db():
    """adds our incidents to the db"""
    db_session()
    crimelist = nabber.epdcrimelist()
    for each in crimelist:
        try:
            test = Incident.query.filter_by(id="%s" % (str(each['ID']))).first()
            print "Record Exists\n\n"
            pass
        except:
            inputid = each['ID']
            inputporesp = each['PoResp']
            inputdescription = each['Description']
            inputofc = each['OFC']
            inputtimerec = each['TimeReceived']
            inputlocation = each['Location']
            inputeventNum = each['EventNum']
            inputpriority = each['Priority']
            inputcaseNo = each['CaseNo']
            incident = Incident(id = inputid, poresp = inputporesp, description = inputdescription, ofc = inputofc, timerec = inputtimerec, location = inputlocation, eventNum = inputeventNum, priority = inputpriority, caseNo = inputcaseNo)
            db_session.add(incident)
            db_session.commit()<commit_msg>added some documentation<commit_after>import sqlite3
import nabber
from dbhandler import db_session, init_db
from models import Incident




def create_db():
    """Creates a sqlite3 database using our models"""
    db_session()
    init_db()
    db_session.remove()

def addto_db():
    """adds our incidents to the db"""
    db_session()
    crimelist = nabber.epdcrimelist()
    for each in crimelist:
        try:
            #checks to see if the incident already exists in the db.
            test = Incident.query.filter_by(id="%s" % (str(each['ID']))).first()
            print "Record Exists\n\n"
            pass
        except:
            inputid = each['ID']
            inputporesp = each['PoResp']
            inputdescription = each['Description']
            inputofc = each['OFC']
            inputtimerec = each['TimeReceived']
            inputlocation = each['Location']
            inputeventNum = each['EventNum']
            inputpriority = each['Priority']
            inputcaseNo = each['CaseNo']

            #create new Incident instance
            incident = Incident(id = inputid, poresp = inputporesp, description = inputdescription, ofc = inputofc, timerec = inputtimerec, location = inputlocation, eventNum = inputeventNum, priority = inputpriority, caseNo = inputcaseNo)

            #add to the database and then commit the changes.
            db_session.add(incident)
            db_session.commit()
{'fraction_non_alphanumeric': 0.1015625, 'fraction_numerical': 0.001488095238095238, 'mean_word_length': 2.4967490247074124, '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': '779030', 'n_tokens_mistral': 756, 'n_tokens_neox': 732, 'n_words': 201}