Questions tagged [fastapi-crudrouter]

9 questions
2
votes
2 answers

How to define multiple API endpoints in FastAPI with different paths but the same path parameter?

I'm working on a project which uses FastAPI. My router file looks like the following: # GET API Endpoint 1 @router.get("/project/{project_id}/{employee_id}") async def method_one( project_id: str, organization_id: str, session: AsyncSession =…
Pranav N
  • 49
  • 5
1
vote
1 answer

Fastapi Sqlalchemy TypeError when returning results from a query that selects columns from two tables

I have copied the below code from a video tutorial, and it is supposed to return the following output. Code @router.get('/', status_code= status.HTTP_200_OK) def get_notes(db: Session = Depends(get_db)): posts = db.query(models.Post,…
1
vote
0 answers

FastAPI Sqlalchemy Error: sqlalchemy.exc.DataError: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type integer: cvb@example.com

Getting error in do_execute cursor.execute(statement, parameters) psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type integer: "cvb@example.com" LINE 3: WHERE "User".id = 'cvb@example.com' while connecting to aws rds…
1
vote
1 answer

fastapi a simple function greet(*args) sdf

I have simple function that takes an arbitrary number of arguments like so: def greet(*args): a=list(args) return {"greetings to users:": a} greet('Aron','Claus') >>>{'greetings to users:': ['Aron', 'Claus']} The function works as…
ttuff
  • 45
  • 5
0
votes
0 answers

why fastapi swagger interface dont update after new code update at same port

fastapi swagger UI is showing the same interface of previous code.for example I had fastapi swagger ui using some html in code.but new code does not have html part.but it is showing the previous int interface even after removing DNS cache. how to…
0
votes
1 answer

Why am I getting {"detail":[{"loc":["path","id"],"msg":"field required","type":"value_error.missing"}]} if I made query with params?

This is the endpoint that is not working: @router.get( "/{question_id}", tags=["questions"], status_code=status.HTTP_200_OK, response_model=Question, dependencies=[Depends(get_db)], ) def get_question(id: int = Path(..., gt=0)): …
sankiago
  • 79
  • 9
0
votes
0 answers

How to add my own field on schema in fastapi users library?

I am using a library called fastapi users for user authentication it's working fine but can't add extra field like they shown here I used this example with sql alchemy Here is my code import uuid from fastapi_users import schemas, models from…
MD SHAYON
  • 7,001
  • 45
  • 38
0
votes
0 answers

fastapi-crudrouter: how to pass url parameter to dependency?

While I am using fastapi-crudrouter am trying to have a resource be accessed only by its owner. Somehow I am getting the error { "detail": [ { "loc": [ "query", "id" ], "msg": "field required", "type":…
O. Altun
  • 685
  • 7
  • 20
-1
votes
1 answer

Get multiple items given an arbitrary query -> Python FastAPi

Get multiple items given an arbitrary query. I am trying to achieve this using Python Fastapi, this is what I did in routes, def get_props_query( *, session: Session = Depends(get_session), query: Optional[Props] = Query( …
gourav
  • 33
  • 7