-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathshell.py
executable file
·37 lines (26 loc) · 983 Bytes
/
shell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
from __future__ import annotations
from os import environ
environ["DISABLE_UVLOOP"] = "1"
import nest_asyncio
from asgiref.sync import async_to_sync
from IPython import embed
from spellbot.database import db_session_manager, initialize_connection
@async_to_sync()
async def runner() -> None:
banner = ["from spellbot.database import DatabaseSession"]
await initialize_connection("spellbot-bot", run_migrations=True)
async with db_session_manager():
from spellbot.database import DatabaseSession
from spellbot.models import Base
for m in Base.registry.mappers: # type: ignore
globals()[m.class_.__name__] = m.class_
banner.append(f"from spellbot.models import {m.class_.__name__}")
globals()["DatabaseSession"] = DatabaseSession
embed(
colors="neutral",
using="asyncio",
banner2="\n".join(banner),
)
nest_asyncio.apply()
runner()