Spaces:
Running
on
Zero
Running
on
Zero
fだ
Browse files
routers/gra_02_openInterpreter/OpenInterpreter.py
CHANGED
@@ -68,6 +68,25 @@ from datetime import datetime
|
|
68 |
db_name = "chat_historys.db"
|
69 |
|
70 |
def initialize_db():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
conn = sqlite3.connect(db_name)
|
72 |
cursor = conn.cursor()
|
73 |
cursor.execute("""
|
|
|
68 |
db_name = "chat_historys.db"
|
69 |
|
70 |
def initialize_db():
|
71 |
+
# データベースファイルが存在しない場合に新しく作成
|
72 |
+
if not os.path.exists(db_name):
|
73 |
+
conn = sqlite3.connect(db_name)
|
74 |
+
cursor = conn.cursor()
|
75 |
+
# テーブルを作成するSQL文
|
76 |
+
create_table_query = """
|
77 |
+
CREATE TABLE IF NOT EXISTS chat_history (
|
78 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
79 |
+
user TEXT NOT NULL,
|
80 |
+
message TEXT NOT NULL,
|
81 |
+
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
|
82 |
+
)
|
83 |
+
"""
|
84 |
+
cursor.execute(create_table_query)
|
85 |
+
conn.commit()
|
86 |
+
conn.close()
|
87 |
+
print("データベースとテーブルが作成されました。")
|
88 |
+
else:
|
89 |
+
print("データベースは既に存在しています。")
|
90 |
conn = sqlite3.connect(db_name)
|
91 |
cursor = conn.cursor()
|
92 |
cursor.execute("""
|