NLP_genAI_final / dashboard.py
irebmann's picture
Initial upload: local files to Hugging Face repo
135f6a8
import sqlite3
class NewsDatabase:
def __init__(self, db_path):
self.conn = sqlite3.connect(db_path)
self.init_db()
def init_db(self):
c = self.conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS alerts (timestamp TEXT, ticker TEXT, headline TEXT, summary TEXT, sentiment REAL, impact_keywords TEXT, urgency REAL)''')
self.conn.commit()
def save_alert(self, alert):
c = self.conn.cursor()
c.execute('''INSERT INTO alerts VALUES (?,?,?,?,?,?,?)''', (
alert['timestamp'], alert['ticker'], alert['headline'], alert['summary'],
alert['sentiment'], alert['impact_keywords'], alert['urgency_score']
))
self.conn.commit()