Spaces:
Sleeping
Sleeping
import sqlite3 | |
def init_db(): | |
conn = sqlite3.connect("db/careercoach.db") | |
c = conn.cursor() | |
c.execute('''CREATE TABLE IF NOT EXISTS chats ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
question TEXT, | |
answer TEXT, | |
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP | |
)''') | |
conn.commit() | |
conn.close() | |
def save_chat(question, answer): | |
conn = sqlite3.connect("db/careercoach.db") | |
c = conn.cursor() | |
c.execute("INSERT INTO chats (question, answer) VALUES (?, ?)", (question, answer)) | |
conn.commit() | |
conn.close() | |