wownero-funding-system/wowfunding/orm/connect.py
Sander Ferdinand edb3d8f57b Initial commit
2018-06-27 01:16:29 +02:00

18 lines
634 B
Python

from datetime import datetime
import sqlalchemy as sa
from sqlalchemy.orm import scoped_session, sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base
import settings
def create_session():
from wowfunding.orm.orm import base
engine = sa.create_engine(settings.SQLALCHEMY_DATABASE_URI, echo=False, encoding="latin")
session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
base.query = session.query_property()
base.metadata.create_all(bind=engine)
return session