AIcareerCoach / database.py
Hyma7's picture
Upload 7 files
5f81bcf verified
raw
history blame contribute delete
588 Bytes
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()