<commit_before># -*- coding: utf-8 -*-

from os.path import realpath, dirname, join
from re import compile
from sqlite3 import connect


class SafeBase:
    
    def __init__(self, g, database_filename):
        self.g = g
        posizione = dirname(realpath(__file__))
        self.percorso = join(posizione, database_filename)
        self.init_db()
    
    def init_db(self):
        database = connect(self.percorso)
        cursore = database.cursor()
        cursore.execute('''
            CREATE TABLE IF NOT EXISTS utente (
                username TEXT PRIMARY KEY,
                password TEXT NOT NULL,
                chiave TEXT NOT NULL,
                sale TEXT NOT NULL
            )
        ''')
        database.commit()
        cursore.execute('''
            CREATE TABLE IF NOT EXISTS profilo (
                username TEXT PRIMARY KEY,
                nome TEXT,
                cognome TEXT,
                stato TEXT,
                foto TEXT
            )
        ''')
        database.commit()
        cursore.execute('''
            CREATE TABLE IF NOT EXISTS messaggio (
                chiave INT NOT NULL AUTOINCREMENT,
                proprietario TEXT NOT NULL,
                partecipante TEXT NOT NULL,
                mittente TEXT NOT NULL,
                immagine INT DEFAULT 0,
                testo TEXT NOT NULL,
                data_ora DATETIME DEFAULT CURRENT_TIMESTAMP,
                letto INT DEFAULT 0
            )<commit_msg>aggiunto limite messaggi per conversazione #2<commit_after># -*- coding: utf-8 -*-

from os.path import realpath, dirname, join
from re import compile
from sqlite3 import connect


class SafeBase:
    
    def __init__(self, g, database_filename):
        self.g = g
        posizione = dirname(realpath(__file__))
        self.percorso = join(posizione, database_filename)
        self.init_db()
    
    def init_db(self):
        database = connect(self.percorso)
        cursore = database.cursor()
        cursore.execute('''
            CREATE TABLE IF NOT EXISTS utente (
                username TEXT PRIMARY KEY,
                password TEXT NOT NULL,
                chiave TEXT NOT NULL,
                sale TEXT NOT NULL
            )
        ''')
        database.commit()
        cursore.execute('''
            CREATE TABLE IF NOT EXISTS profilo (
                username TEXT PRIMARY KEY,
                nome TEXT,
                cognome TEXT,
                stato TEXT,
                foto TEXT
            )
        ''')
        database.commit()
        cursore.execute('''
            CREATE TABLE IF NOT EXISTS messaggio (
                chiave INTEGER NOT NULL AUTOINCREMENT,
                proprietario TEXT NOT NULL,
                partecipante TEXT NOT NULL,
                mittente TEXT NOT NULL,
                immagine INT DEFAULT 0,
                testo TEXT NOT NULL,
                data_ora DATETIME DEFAULT CURRENT_TIMESTAMP,
                letto INT DEFAULT 0
            )
{'fraction_non_alphanumeric': 0.06420492348636062, 'fraction_numerical': 0.0029940119760479044, 'mean_word_length': 1.413322632423756, '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': '2191409', 'n_tokens_mistral': 813, 'n_tokens_neox': 751, 'n_words': 247}