KTI / update_db.py
noranisa's picture
Upload 63 files
b66f2ff verified
Raw
History Blame Contribute Delete
704 Bytes
import sqlite3
import os
db_path = os.path.join('data', 'literature_cache.db')
if not os.path.exists(db_path):
print("Database tidak ditemukan, mungkin Anda menggunakan path yang berbeda.")
else:
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
try:
cursor.execute("ALTER TABLE user ADD COLUMN semantic_scholar_api_key VARCHAR(200)")
conn.commit()
print("βœ… Kolom semantic_scholar_api_key berhasil ditambahkan ke tabel user!")
except sqlite3.OperationalError as e:
if "duplicate column name" in str(e):
print("βœ… Kolom sudah ada, tidak perlu ditambahkan lagi.")
else:
print(f"❌ Error: {e}")
conn.close()