-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
20 lines (16 loc) Β· 747 Bytes
/
models.py
File metadata and controls
20 lines (16 loc) Β· 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
password = db.Column(db.String(120), nullable=False)
class Product(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
price = db.Column(db.Float, nullable=False)
company = db.Column(db.String(100), nullable=False)
category = db.Column(db.String(100), nullable=False) # π Added Category
use = db.Column(db.String(200), nullable=False)
stock = db.Column(db.Integer, nullable=False, default=0)
def __repr__(self):
return f"<Product {self.name}>"