Spaces:
Runtime error
Runtime error
new rooms schema
Browse files
createRooms.py β stablediffusion-infinity/createRooms.py
RENAMED
@@ -9,12 +9,20 @@ import json
|
|
9 |
app = FastAPI()
|
10 |
LIVEBLOCKS_SECRET = os.environ.get("LIVEBLOCKS_SECRET")
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
def get_db():
|
14 |
db = sqlite3.connect(Path("./rooms.db"), check_same_thread=False)
|
15 |
-
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)")
|
16 |
print("Connected to database")
|
17 |
-
db.commit()
|
18 |
db.row_factory = sqlite3.Row
|
19 |
try:
|
20 |
yield db
|
@@ -26,7 +34,7 @@ def get_db():
|
|
26 |
|
27 |
app = FastAPI()
|
28 |
|
29 |
-
rooms = ["
|
30 |
|
31 |
|
32 |
@app.get("/")
|
@@ -109,4 +117,4 @@ async def sync_rooms(db: sqlite3.Connection = Depends(get_db)):
|
|
109 |
|
110 |
|
111 |
if __name__ == "__main__":
|
112 |
-
uvicorn.run("
|
|
|
9 |
app = FastAPI()
|
10 |
LIVEBLOCKS_SECRET = os.environ.get("LIVEBLOCKS_SECRET")
|
11 |
|
12 |
+
DB_PATH = Path("rooms.db")
|
13 |
+
if not DB_PATH.exists():
|
14 |
+
print("Creating database")
|
15 |
+
print("DB_PATH", DB_PATH)
|
16 |
+
db = sqlite3.connect(DB_PATH)
|
17 |
+
with open(Path("schema.sql"), "r") as f:
|
18 |
+
db.executescript(f.read())
|
19 |
+
db.commit()
|
20 |
+
db.close()
|
21 |
+
|
22 |
|
23 |
def get_db():
|
24 |
db = sqlite3.connect(Path("./rooms.db"), check_same_thread=False)
|
|
|
25 |
print("Connected to database")
|
|
|
26 |
db.row_factory = sqlite3.Row
|
27 |
try:
|
28 |
yield db
|
|
|
34 |
|
35 |
app = FastAPI()
|
36 |
|
37 |
+
rooms = ["room-" + str(i) for i in range(0, 41)]
|
38 |
|
39 |
|
40 |
@app.get("/")
|
|
|
117 |
|
118 |
|
119 |
if __name__ == "__main__":
|
120 |
+
uvicorn.run("createRooms:app", host="0.0.0.0", log_level="debug", reload=True)
|
stablediffusion-infinity/schema.sql
CHANGED
@@ -1,26 +1,47 @@
|
|
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,'
|
5 |
-
INSERT INTO rooms VALUES(2,'
|
6 |
-
INSERT INTO rooms VALUES(3,'
|
7 |
-
INSERT INTO rooms VALUES(4,'
|
8 |
-
INSERT INTO rooms VALUES(5,'
|
9 |
-
INSERT INTO rooms VALUES(6,'
|
10 |
-
INSERT INTO rooms VALUES(7,'
|
11 |
-
INSERT INTO rooms VALUES(8,'
|
12 |
-
INSERT INTO rooms VALUES(9,'
|
13 |
-
INSERT INTO rooms VALUES(10,'
|
14 |
-
INSERT INTO rooms VALUES(11,'
|
15 |
-
INSERT INTO rooms VALUES(12,'
|
16 |
-
INSERT INTO rooms VALUES(13,'
|
17 |
-
INSERT INTO rooms VALUES(14,'
|
18 |
-
INSERT INTO rooms VALUES(15,'
|
19 |
-
INSERT INTO rooms VALUES(16,'
|
20 |
-
INSERT INTO rooms VALUES(17,'
|
21 |
-
INSERT INTO rooms VALUES(18,'
|
22 |
-
INSERT INTO rooms VALUES(19,'
|
23 |
-
INSERT INTO rooms VALUES(20,'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
DELETE FROM sqlite_sequence;
|
25 |
-
INSERT INTO sqlite_sequence VALUES('rooms',
|
26 |
COMMIT;
|
|
|
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,'room-0',0);
|
5 |
+
INSERT INTO rooms VALUES(2,'room-1',0);
|
6 |
+
INSERT INTO rooms VALUES(3,'room-2',0);
|
7 |
+
INSERT INTO rooms VALUES(4,'room-3',0);
|
8 |
+
INSERT INTO rooms VALUES(5,'room-4',0);
|
9 |
+
INSERT INTO rooms VALUES(6,'room-5',0);
|
10 |
+
INSERT INTO rooms VALUES(7,'room-6',0);
|
11 |
+
INSERT INTO rooms VALUES(8,'room-7',0);
|
12 |
+
INSERT INTO rooms VALUES(9,'room-8',0);
|
13 |
+
INSERT INTO rooms VALUES(10,'room-9',0);
|
14 |
+
INSERT INTO rooms VALUES(11,'room-10',0);
|
15 |
+
INSERT INTO rooms VALUES(12,'room-11',0);
|
16 |
+
INSERT INTO rooms VALUES(13,'room-12',0);
|
17 |
+
INSERT INTO rooms VALUES(14,'room-13',0);
|
18 |
+
INSERT INTO rooms VALUES(15,'room-14',0);
|
19 |
+
INSERT INTO rooms VALUES(16,'room-15',0);
|
20 |
+
INSERT INTO rooms VALUES(17,'room-16',0);
|
21 |
+
INSERT INTO rooms VALUES(18,'room-17',0);
|
22 |
+
INSERT INTO rooms VALUES(19,'room-18',0);
|
23 |
+
INSERT INTO rooms VALUES(20,'room-19',0);
|
24 |
+
INSERT INTO rooms VALUES(21,'room-20',0);
|
25 |
+
INSERT INTO rooms VALUES(22,'room-21',0);
|
26 |
+
INSERT INTO rooms VALUES(23,'room-22',0);
|
27 |
+
INSERT INTO rooms VALUES(24,'room-23',0);
|
28 |
+
INSERT INTO rooms VALUES(25,'room-24',0);
|
29 |
+
INSERT INTO rooms VALUES(26,'room-25',0);
|
30 |
+
INSERT INTO rooms VALUES(27,'room-26',0);
|
31 |
+
INSERT INTO rooms VALUES(28,'room-27',0);
|
32 |
+
INSERT INTO rooms VALUES(29,'room-28',0);
|
33 |
+
INSERT INTO rooms VALUES(30,'room-29',0);
|
34 |
+
INSERT INTO rooms VALUES(31,'room-30',0);
|
35 |
+
INSERT INTO rooms VALUES(32,'room-31',0);
|
36 |
+
INSERT INTO rooms VALUES(33,'room-32',0);
|
37 |
+
INSERT INTO rooms VALUES(34,'room-33',0);
|
38 |
+
INSERT INTO rooms VALUES(35,'room-34',0);
|
39 |
+
INSERT INTO rooms VALUES(36,'room-35',0);
|
40 |
+
INSERT INTO rooms VALUES(37,'room-36',0);
|
41 |
+
INSERT INTO rooms VALUES(38,'room-37',0);
|
42 |
+
INSERT INTO rooms VALUES(39,'room-38',0);
|
43 |
+
INSERT INTO rooms VALUES(40,'room-39',0);
|
44 |
+
INSERT INTO rooms VALUES(41,'room-40',0);
|
45 |
DELETE FROM sqlite_sequence;
|
46 |
+
INSERT INTO sqlite_sequence VALUES('rooms',41);
|
47 |
COMMIT;
|