Boobs00 commited on
Commit
9d6574c
·
verified ·
1 Parent(s): ed44960

Create models.py

Browse files
Files changed (1) hide show
  1. models.py +16 -0
models.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask_sqlalchemy import SQLAlchemy
2
+
3
+ db = SQLAlchemy()
4
+
5
+ class User(db.Model):
6
+ id = db.Column(db.Integer, primary_key=True)
7
+ username = db.Column(db.String(64), unique=True, nullable=False)
8
+ password_hash = db.Column(db.String(128), nullable=False)
9
+ searches = db.relationship('SearchHistory', backref='user', lazy=True)
10
+
11
+ class SearchHistory(db.Model):
12
+ id = db.Column(db.Integer, primary_key=True)
13
+ query = db.Column(db.String(512), nullable=False)
14
+ filters = db.Column(db.String(256), nullable=True)
15
+ timestamp = db.Column(db.DateTime, nullable=False)
16
+ user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)