Spaces:
Runtime error
Runtime error
remove db from repo
Browse files- .gitignore +2 -1
- stablediffusion-infinity/app.py +7 -4
- stablediffusion-infinity/rooms.db +0 -0
- stablediffusion-infinity/schema.sql +26 -0
.gitignore
CHANGED
|
@@ -16,4 +16,5 @@ __pycache__/
|
|
| 16 |
flagged/
|
| 17 |
data
|
| 18 |
data.db
|
| 19 |
-
data.json
|
|
|
|
|
|
| 16 |
flagged/
|
| 17 |
data
|
| 18 |
data.db
|
| 19 |
+
data.json
|
| 20 |
+
rooms.db
|
stablediffusion-infinity/app.py
CHANGED
|
@@ -37,15 +37,18 @@ DB_PATH = Path("rooms.db")
|
|
| 37 |
|
| 38 |
app = FastAPI()
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
def get_db():
|
| 44 |
db = sqlite3.connect(DB_PATH, check_same_thread=False)
|
| 45 |
-
db.execute("CREATE TABLE IF NOT EXISTS rooms (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, room_id TEXT NOT NULL, users_count INTEGER NOT NULL DEFAULT 0)")
|
| 46 |
-
print("Connected to database")
|
| 47 |
-
db.commit()
|
| 48 |
db.row_factory = sqlite3.Row
|
|
|
|
| 49 |
try:
|
| 50 |
yield db
|
| 51 |
except Exception:
|
|
|
|
| 37 |
|
| 38 |
app = FastAPI()
|
| 39 |
|
| 40 |
+
if not DB_PATH.exists():
|
| 41 |
+
print("Creating database")
|
| 42 |
+
print("DB_PATH", DB_PATH)
|
| 43 |
+
db = sqlite3.connect(DB_PATH)
|
| 44 |
+
with open(Path("schema.sql"), "r") as f:
|
| 45 |
+
db.executescript(f.read())
|
| 46 |
|
| 47 |
|
| 48 |
def get_db():
|
| 49 |
db = sqlite3.connect(DB_PATH, check_same_thread=False)
|
|
|
|
|
|
|
|
|
|
| 50 |
db.row_factory = sqlite3.Row
|
| 51 |
+
print("Connected to database")
|
| 52 |
try:
|
| 53 |
yield db
|
| 54 |
except Exception:
|
stablediffusion-infinity/rooms.db
DELETED
|
Binary file (12.3 kB)
|
|
|
stablediffusion-infinity/schema.sql
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
PRAGMA foreign_keys=OFF;
|
| 2 |
+
BEGIN TRANSACTION;
|
| 3 |
+
CREATE TABLE rooms (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, room_id TEXT NOT NULL, users_count INTEGER NOT NULL DEFAULT 0);
|
| 4 |
+
INSERT INTO rooms VALUES(1,'sd-multiplayer-room-0',0);
|
| 5 |
+
INSERT INTO rooms VALUES(2,'sd-multiplayer-room-1',0);
|
| 6 |
+
INSERT INTO rooms VALUES(3,'sd-multiplayer-room-2',0);
|
| 7 |
+
INSERT INTO rooms VALUES(4,'sd-multiplayer-room-3',0);
|
| 8 |
+
INSERT INTO rooms VALUES(5,'sd-multiplayer-room-4',0);
|
| 9 |
+
INSERT INTO rooms VALUES(6,'sd-multiplayer-room-5',0);
|
| 10 |
+
INSERT INTO rooms VALUES(7,'sd-multiplayer-room-6',0);
|
| 11 |
+
INSERT INTO rooms VALUES(8,'sd-multiplayer-room-7',0);
|
| 12 |
+
INSERT INTO rooms VALUES(9,'sd-multiplayer-room-8',0);
|
| 13 |
+
INSERT INTO rooms VALUES(10,'sd-multiplayer-room-9',0);
|
| 14 |
+
INSERT INTO rooms VALUES(11,'sd-multiplayer-room-10',0);
|
| 15 |
+
INSERT INTO rooms VALUES(12,'sd-multiplayer-room-11',0);
|
| 16 |
+
INSERT INTO rooms VALUES(13,'sd-multiplayer-room-12',0);
|
| 17 |
+
INSERT INTO rooms VALUES(14,'sd-multiplayer-room-13',0);
|
| 18 |
+
INSERT INTO rooms VALUES(15,'sd-multiplayer-room-14',0);
|
| 19 |
+
INSERT INTO rooms VALUES(16,'sd-multiplayer-room-15',0);
|
| 20 |
+
INSERT INTO rooms VALUES(17,'sd-multiplayer-room-16',0);
|
| 21 |
+
INSERT INTO rooms VALUES(18,'sd-multiplayer-room-17',0);
|
| 22 |
+
INSERT INTO rooms VALUES(19,'sd-multiplayer-room-18',0);
|
| 23 |
+
INSERT INTO rooms VALUES(20,'sd-multiplayer-room-19',0);
|
| 24 |
+
DELETE FROM sqlite_sequence;
|
| 25 |
+
INSERT INTO sqlite_sequence VALUES('rooms',20);
|
| 26 |
+
COMMIT;
|