Task finished #1

Merged
skrazzo merged 10 commits from Uzdevums into main 2025-07-02 22:45:40 +03:00
2 changed files with 16 additions and 4 deletions
Showing only changes of commit acb81d671d - Show all commits

View File

@@ -3,9 +3,21 @@ from db.db import get_db
conn = get_db()
def get_users():
def get_users(search):
# Get search param
search_param = f"%{search}%"
print(search_param)
# Generate cursor
cursor = conn.cursor()
cursor.execute("SELECT * FROM Employees")
# Search if needed
if search:
cursor.execute("SELECT * FROM Employees WHERE username LIKE ?", (search_param,))
else:
cursor.execute("SELECT * FROM Employees")
# Fetch users from database
users = cursor.fetchall()
return users

View File

@@ -16,8 +16,8 @@ app.add_middleware(
)
@app.get("/")
def list_users():
return get_users()
def list_users(s: str = None):
return get_users(s)
@app.get("/{eployee_id}")
def list_attendance(eployee_id: int):