Added version 4

This commit is contained in:
2026-01-30 11:47:06 +03:00
parent 05aea043b6
commit 801844807e
2205 changed files with 2048 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
# database.py
import sqlite3
conn = sqlite3.connect('jokes.db')
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS jokes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
joke TEXT NOT NULL,
contributor TEXT NOT NULL,
published TEXT NOT NULL,
sentiment_score REAL DEFAULT 0.0,
sentiment_label TEXT DEFAULT '😐 Neutral'
)''')
# Create a new table to store user sentiments for each joke
cursor.execute('''CREATE TABLE IF NOT EXISTS user_sentiments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
joke_id INTEGER NOT NULL,
user_sentiment TEXT CHECK(user_sentiment IN ('up', 'down', 'neutral')) DEFAULT 'neutral',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (joke_id) REFERENCES jokes(id) ON DELETE CASCADE
)''')
conn.commit()
print("✅ Database and tables created successfully with AI sentiment columns and user sentiment tracking!")
conn.close()