Spaces:
Runtime error
Runtime error
| 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() | |