Spaces:
Sleeping
Sleeping
Download migrate_db.py from Lijoice/StockScout: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/spaces/Lijoice/StockScout/resolve/main/migrate_db.py
- Command line
-
hf download hf://spaces/Lijoice/StockScout/migrate_db.py
-
curl -L -o migrate_db.py https://huggingface.co/spaces/Lijoice/StockScout/resolve/main/migrate_db.py
610 Bytes
| import sqlite3 | |
| import os | |
| db_path = "stock_app.db" | |
| if not os.path.exists(db_path): | |
| print(f"DB not found at {db_path}") | |
| exit(1) | |
| conn = sqlite3.connect(db_path) | |
| cursor = conn.cursor() | |
| try: | |
| cursor.execute("ALTER TABLE stocks ADD COLUMN latest_pros TEXT") | |
| print("Added latest_pros") | |
| except sqlite3.OperationalError: | |
| print("latest_pros already exists") | |
| try: | |
| cursor.execute("ALTER TABLE stocks ADD COLUMN latest_trend FLOAT") | |
| print("Added latest_trend") | |
| except sqlite3.OperationalError: | |
| print("latest_trend already exists") | |
| conn.commit() | |
| conn.close() | |
| print("Migration complete.") | |