<commit_before># -*- coding: utf-8 -*-
"""db/__init__.py
By <NAME>, thePortus.com, <EMAIL>

=================================== DB Module =================================

The DB module houses the schema models and other functions to interact with
the sqlite database. These models will be called from elsewhere (mostly from
the scraper and exporter modules), in order to store and retreive data. If
doing your own project by customizing the scraper module, you should change
these models to reflect the tables you wish to store.
"""
import peewee as sql

from usf_dime_novels.common import settings, Printer


def database(mode='live'):
    sql.SqliteDatabase(settings.LIVE_DB)


def init_db(mode='live'):
    table_list = [
        # List each table model here
    ]
    db = database(mode=mode)
    db.connect()
    missing_tables = []
    for table in table_list:
        if not table.table_exists():
            missing_tables.append(table)
    if len(missing_tables):
        Printer('Building database...')
        for table in missing_tables:
            table.create_table()
        Printer('Database built')
    db.close()<commit_msg>firefox and chrome installations added 9<commit_after># -*- coding: utf-8 -*-
"""db/__init__.py
By <NAME>, thePortus.com, <EMAIL>

=================================== DB Module =================================

The DB module houses the schema models and other functions to interact with
the sqlite database. These models will be called from elsewhere (mostly from
the scraper and exporter modules), in order to store and retreive data. If
doing your own project by customizing the scraper module, you should change
these models to reflect the tables you wish to store.
"""
import peewee as sql

from usf_dime_novels.common import settings, Printer


def database(mode='live'):
    """
    Returns the sqlite database object depending on live or testing mode.
    Currently redundant, since live & testing databases are the same.
    """
    # Return testing dB is specified, otherwise, live dB
    if mode == 'testing':
        return sql.SqliteDatabase(settings.TESTING_DB)
    return sql.SqliteDatabase(settings.LIVE_DB)


def init_db(mode='live'):
    """
    Performs all the initial operations to check the status of the database.
    If tables do not exist for schema models, tables will be created.
    """
    # List of dB models from the schema
    table_list = [
        # List each table model here
    ]
    db = database(mode=mode)
    db.connect()
    missing_tables = []
    # Check each model for a table, append missing to missing_tables
    for table in table_list:
        if not table.table_exists():
            missing_tables.append(table)
    # If missing tables are found, create them
    if len(missing_tables):
        Printer('Building database...')
        for table in missing_tables:
            table.create_table()
        Printer('Database built')
    # Close tb connection
    db.close()
{'fraction_non_alphanumeric': 0.12234580384226491, 'fraction_numerical': 0.0010111223458038423, 'mean_word_length': 3.364705882352941, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '643580', 'n_tokens_mistral': 802, 'n_tokens_neox': 775, 'n_words': 317}