Spaces:
Sleeping
Sleeping
File size: 588 Bytes
5f81bcf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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()
|