SQL Alchemy other Column not selecting in Table

Viewed 23

If i want to search for a specific user with the Username the API returns:

GET /users/test HTTP/1.1" 422 Unprocessable Entity

enter image description here

And if I put an id there it returns the correct id with the correct user. Does smn know the fix

main.py

@app.get("/user/{username}")
async def get_user_username(username: str):
    return conn.execute(users.select().where(users.c.username == username)).fetchall()

models/users.py

users = Table(
    'users',meta,
    Column('id',Integer,primary_key=True),
    Column('username',String),
    Column('password',String)
)

schemas/users.py

from pydantic import BaseModel
class User(BaseModel):
    id:int
    username:str
    password:str
1 Answers

I just had another route where the user id was asked.

Related