Download db/init_db.py from supff/sau: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/supff/sau/resolve/main/db/init_db.py
- Command line
-
hf download hf://spaces/supff/sau/db/init_db.py
-
curl -L -o init_db.py https://huggingface.co/spaces/supff/sau/resolve/main/db/init_db.py
1.04 kB
| import sqlite3 | |
| from pathlib import Path | |
| def ensure_database(base_dir): | |
| db_dir = Path(base_dir) / 'db' | |
| db_dir.mkdir(parents=True, exist_ok=True) | |
| db_path = db_dir / 'database.db' | |
| conn = sqlite3.connect(db_path) | |
| try: | |
| cursor = conn.cursor() | |
| cursor.execute( | |
| ''' | |
| CREATE TABLE IF NOT EXISTS user_info ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| type INTEGER NOT NULL, | |
| filePath TEXT NOT NULL, | |
| userName TEXT NOT NULL, | |
| status INTEGER DEFAULT 0 | |
| ) | |
| ''' | |
| ) | |
| cursor.execute( | |
| ''' | |
| CREATE TABLE IF NOT EXISTS file_records ( | |
| id INTEGER PRIMARY KEY AUTOINCREMENT, | |
| filename TEXT NOT NULL, | |
| filesize REAL, | |
| upload_time DATETIME DEFAULT CURRENT_TIMESTAMP, | |
| file_path TEXT | |
| ) | |
| ''' | |
| ) | |
| conn.commit() | |
| finally: | |
| conn.close() | |
| return db_path | |