create database for broadcast
added database structure for running broadcast function
This commit is contained in:
parent
db97c04c1f
commit
c6f7dc0457
29
driver/database/__init__.py
Normal file
29
driver/database/__init__.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||||
|
|
||||||
|
from config import DATABASE_URL as db
|
||||||
|
|
||||||
|
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()
|
Loading…
Reference in New Issue
Block a user