mirror of https://gitlab.com/akasroua/covot
Rename users table to user
This commit is contained in:
parent
2d6597988c
commit
5ff70715c8
|
@ -2,7 +2,7 @@ from sqlalchemy import or_
|
|||
from sqlalchemy.orm import Query
|
||||
|
||||
from database import SessionLocal, engine, models
|
||||
from database.models import Users
|
||||
from database.models import User
|
||||
|
||||
db = SessionLocal()
|
||||
|
||||
|
@ -11,8 +11,8 @@ def search_database(id) -> Query:
|
|||
"""
|
||||
Returns the user associated with the id argument
|
||||
"""
|
||||
return db.query(Users).filter(
|
||||
or_(Users.correo_institucional == id, Users.numero_de_documento == id)
|
||||
return db.query(User).filter(
|
||||
or_(User.correo_institucional == id, User.numero_de_documento == id)
|
||||
)
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ def insert_data(data) -> None:
|
|||
"""
|
||||
Inserts a new user into the database
|
||||
"""
|
||||
item = Users(**data)
|
||||
item = User(**data)
|
||||
db.add(item)
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
|
@ -41,9 +41,9 @@ def save_attribute(attribute, data) -> None:
|
|||
"""
|
||||
Updates the attribute value with the content of data
|
||||
"""
|
||||
key = eval("Users." + attribute)
|
||||
db.query(Users).filter(
|
||||
or_(Users.correo_institucional == id, Users.numero_de_documento == id)
|
||||
key = eval("User." + attribute)
|
||||
db.query(User).filter(
|
||||
or_(User.correo_institucional == id, User.numero_de_documento == id)
|
||||
).update({key: data})
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ from sqlalchemy.types import Date, Integer, String, Text
|
|||
from database import Base
|
||||
|
||||
|
||||
class Users(Base):
|
||||
__tablename__ = "users"
|
||||
class User(Base):
|
||||
__tablename__ = "user"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
primer_apellido = Column(String, nullable=False)
|
||||
|
|
Loading…
Reference in New Issue