From c8b65e443350da90c09732f021e78bc3aae7f9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phillip=20K=C3=BChne?= Date: Wed, 4 Oct 2023 00:33:15 +0000 Subject: [PATCH] Ensure Index exists after Song import --- backend/database.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/database.py b/backend/database.py index a7b0292..ba9c731 100644 --- a/backend/database.py +++ b/backend/database.py @@ -28,6 +28,11 @@ def import_songs(song_csv): with get_db_engine().connect() as conn: df.to_sql(song_table, conn, if_exists='replace', index=False) + try: + cur = conn.execute(text("ALTER TABLE songs ADD FULLTEXT(Title,Artist)")) + conn.commit() + except Exception: + pass cur = conn.execute(text("SELECT Count(Id) FROM songs")) num_songs = cur.fetchone()[0] # type: ignore conn.commit()