2021-11-13 23:51:47 +00:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2021-11-14 11:39:51 +00:00
|
|
|
from driver.veez import user as app
|
2021-11-13 23:51:47 +00:00
|
|
|
from sqlalchemy import create_engine
|
2021-11-13 23:53:08 +00:00
|
|
|
from config import DATABASE_URL as db
|
2021-11-13 23:51:47 +00:00
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
|
|
|
|
|
|
|
if db and db.startswith("postgres://"):
|
|
|
|
app = db.replace("postgres://", "postgresql://", 1)
|
|
|
|
|
|
|
|
BASE = declarative_base()
|
|
|
|
|
|
|
|
def start() -> scoped_session:
|
|
|
|
engine = create_engine(app)
|
|
|
|
BASE.metadata.bind = engine
|
|
|
|
BASE.metadata.create_all(engine)
|
|
|
|
return scoped_session(sessionmaker(bind=engine, autoflush=False))
|
|
|
|
|
|
|
|
SESSION = start()
|