from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin

db = SQLAlchemy()

class Student(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    age = db.Column(db.Integer, nullable=False)
    grade = db.Column(db.String(10), nullable=False)

    def __repr__(self):
        return f'<Student {self.name}>'

class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy
    email = db.Column(db.String(100), unique=True)
    password = db.Column(db.String(100))
    name = db.Column(db.String(1000))

class Carburante(db.Model):
    identificador = db.Column(db.Integer, primary_key=True)
    fecha = db.Column(db.Date())
    vehiculo = db.Column(db.String(20))
    kms = db.Column(db.Integer)
    litros = db.Column(db.DECIMAL(10,3))    
    descuento = db.Column(db.DECIMAL(10,2))
    precioxlitro = db.Column(db.DECIMAL(10,3))
    importe = db.Column(db.DECIMAL(10,2))

class Vehiculos(db.Model):
  identificador = db.Column(db.Integer, primary_key=True)
  marca = db.Column(db.String(20))
  modelo = db.Column(db.String(20))
  matricula = db.Column(db.String(20))
