forked from DevsExpo/AccountGenBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_main.py
More file actions
26 lines (20 loc) · 720 Bytes
/
sql_main.py
File metadata and controls
26 lines (20 loc) · 720 Bytes
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
import os
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
# the secret configuration specific things
from Configs import Config
def start() -> scoped_session:
engine = create_engine(Config.DB_URI)
BASE.metadata.bind = engine
BASE.metadata.create_all(engine)
return scoped_session(sessionmaker(bind=engine, autoflush=False))
try:
BASE = declarative_base()
SESSION = start()
except AttributeError as e:
# this is a dirty way for the work-around required for #23
print(
"DB_URI is not configured. Features depending on the database might have issues."
)
print(str(e))