-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.py
26 lines (18 loc) · 914 Bytes
/
database.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Favorite(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(255), nullable=False)
subtitle = db.Column(db.String(255), nullable=False)
uid = db.Column(db.String(255), nullable=True)
taken = db.Column(db.Boolean, default=False)
class Picture(db.Model):
id = db.Column(db.Integer, primary_key=True)
path = db.Column(db.String(255), nullable=False)
favorite_id = db.Column(db.Integer, db.ForeignKey(Favorite.id), nullable=False)
favorite = db.relationship(Favorite, backref=db.backref('pictures', lazy='dynamic'))
class Url(db.Model):
id = db.Column(db.Integer, primary_key=True)
favorite_id = db.Column(db.Integer, db.ForeignKey(Favorite.id), nullable=False)
favorite = db.relationship(Favorite, backref=db.backref('urls', lazy='dynamic'))