Commit f616d3b0 authored by David Trattnig's avatar David Trattnig
Browse files

Fixed initialization of Model & Session;

parent 5607ffbb
......@@ -27,6 +27,9 @@ import time
import logging
import datetime
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import orm, func, BigInteger, Boolean, Column, DateTime, Integer, String, ForeignKey, ForeignKeyConstraint
from sqlalchemy.orm import relationship
from sqlalchemy.sql.expression import false, true
......@@ -36,11 +39,20 @@ from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from libraries.enum.auraenumerations import ScheduleEntryType
from aura import DB
from libraries.base.config import AuraConfig
from modules.base.simpleutil import SimpleUtil
engine = sa.create_engine(AuraConfig().get_database_uri())
Base = declarative_base()
Base.metadata.bind = engine
class DB():
session = orm.scoped_session(orm.sessionmaker())(bind=engine)
Model = Base
class AuraDatabaseModel():
"""
......@@ -89,8 +101,10 @@ class AuraDatabaseModel():
manualschedule = Schedule()
manualschedule.schedule_id = 0
manualschedule.show_name = "Manual Show"
DB.drop_all()
DB.create_all()
Base.metadata.drop_all()
Base.metadata.create_all()
# self.logger.debug("inserting manual scheduling possibility and fallback trackservice schedule")
# DB.session.add(manualschedule)
# db.session.add(fallback_trackservice_schedule)
......@@ -346,7 +360,7 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
# relationships
playlist = relationship("Playlist", uselist=False, back_populates="entries")
meta_data = relationship("PlaylistEntryMetaData", back_populates="entry")
meta_data = relationship("PlaylistEntryMetaData", uselist=False, back_populates="entry")
@staticmethod
def select_playlistentry_for_playlist(artificial_playlist_id, entry_num):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment