From 9ddf85ce5a0396637a7ab6a12099ad974e8e7b7a Mon Sep 17 00:00:00 2001 From: G3G4X5X6 <87740076+G3G4X5X6@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:05:05 +0800 Subject: [PATCH] fixed: sqlite3.OperationalError: table logs already exists (#5677) CREATE TABLE IF NOT EXISTS --- lib/utils/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/utils/api.py b/lib/utils/api.py index ef1dafdc6..b3d4f38fa 100644 --- a/lib/utils/api.py +++ b/lib/utils/api.py @@ -122,9 +122,9 @@ class Database(object): return self.cursor.fetchall() def init(self): - self.execute("CREATE TABLE logs(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, time TEXT, level TEXT, message TEXT)") - self.execute("CREATE TABLE data(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, status INTEGER, content_type INTEGER, value TEXT)") - self.execute("CREATE TABLE errors(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, error TEXT)") + self.execute("CREATE TABLE IF NOT EXISTS logs(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, time TEXT, level TEXT, message TEXT)") + self.execute("CREATE TABLE IF NOT EXISTS data(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, status INTEGER, content_type INTEGER, value TEXT)") + self.execute("CREATE TABLE IF NOT EXISTS errors(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, error TEXT)") class Task(object): def __init__(self, taskid, remote_addr):