コード例 #1
0
    def create_dao(c: config.Config):
        dao = Dao()
        e = create_points_engine(c)
        session = sessionmaker()
        session.configure(bind=e)
        base = get_base()
        base.metadata.create_all(e)
        dao.__session_maker = session

        return dao
コード例 #2
0
ファイル: point_set.py プロジェクト: thealtered7/points
import points.model.point as point
import points.utils as p_utils
import json
import points.model.base as base
from sqlalchemy import Column, Integer, String, TIMESTAMP
from sqlalchemy.orm import relationship, backref

Base = base.get_base()


class PointSet(Base):
    __tablename__ = "point_set"
    id = Column(Integer, primary_key=True)
    created = Column(TIMESTAMP, nullable=False)
    name = Column(String, nullable=False)
    points = relationship(point.Point,
                          backref=backref('point',
                                          uselist=True,
                                          cascade="delete,all"))

    def __init__(self):
        Base.__init__(self)
        self.name = ""
        self.created = None
        self.id = None
        self.points = []

    def __repr__(self):
        return ", ".join(
            ["{}: {}".format(k, v) for k, v in self.__dict__.items()])