Skip to content

Commit 5282984

Browse files
author
SM_SAYEED
committed
"Reset and repopulate music_clips from CSV"
1 parent 49b670c commit 5282984

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

app.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,18 @@ def migrate_csv_to_db():
479479
with sqlite3.connect(DB_NAME) as conn:
480480
c = conn.cursor()
481481

482-
# Step 1: Clear existing table
483-
c.execute("DELETE FROM music_clips")
484-
485-
# Step 2: Re-read CSV and insert each entry
482+
# Step 1: Drop and recreate table
483+
c.execute("DROP TABLE IF EXISTS music_clips")
484+
c.execute('''
485+
CREATE TABLE music_clips (
486+
id INTEGER PRIMARY KEY AUTOINCREMENT,
487+
filename TEXT,
488+
title TEXT,
489+
description TEXT
490+
)
491+
''')
492+
493+
# Step 2: Insert from CSV
486494
with open(csv_path, encoding='utf-8') as f:
487495
reader = csv.DictReader(f)
488496
for row in reader:
@@ -498,10 +506,9 @@ def migrate_csv_to_db():
498506
)
499507

500508
conn.commit()
501-
return "✅ Database refreshed from CSV!"
502-
509+
return "✅ Table recreated and data loaded from CSV!"
503510
except Exception as e:
504-
return f"❌ Error during migration: {e}"
511+
return f"❌ Error: {e}"
505512

506513
# SEARCH ROUTE
507514
@app.route('/search')

fly.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ primary_region = 'ams'
1919
[http_service]
2020
internal_port = 8080
2121
force_https = true
22-
auto_stop_machines = 'stop'
2322
auto_start_machines = true
24-
min_machines_running = 0
25-
processes = ['app']
23+
auto_stop_machines = false
24+
min_machines_running = 1
25+
2626

2727
[[vm]]
2828
memory = '1gb'

0 commit comments

Comments
 (0)