none
This commit is contained in:
parent
c6f7dc0457
commit
1356c93862
@ -1,29 +1,20 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
from config import DATABASE_URL as db
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||||
|
|
||||||
from config import DATABASE_URL as db
|
|
||||||
|
|
||||||
if db and db.startswith("postgres://"):
|
if db and db.startswith("postgres://"):
|
||||||
|
|
||||||
app = db.replace("postgres://", "postgresql://", 1)
|
app = db.replace("postgres://", "postgresql://", 1)
|
||||||
|
|
||||||
BASE = declarative_base()
|
BASE = declarative_base()
|
||||||
|
|
||||||
def start() -> scoped_session:
|
def start() -> scoped_session:
|
||||||
|
|
||||||
engine = create_engine(app)
|
engine = create_engine(app)
|
||||||
|
|
||||||
BASE.metadata.bind = engine
|
BASE.metadata.bind = engine
|
||||||
|
|
||||||
BASE.metadata.create_all(engine)
|
BASE.metadata.create_all(engine)
|
||||||
|
|
||||||
return scoped_session(sessionmaker(bind=engine, autoflush=False))
|
return scoped_session(sessionmaker(bind=engine, autoflush=False))
|
||||||
|
|
||||||
SESSION = start()
|
SESSION = start()
|
||||||
|
Loading…
Reference in New Issue
Block a user