LuisLuii / FastAPIQuickCRUD

Generate CRUD methods in FastApi from an SQLAlchemy schema
https://pypi.org/project/fastapi-quickcrud/
MIT License
252 stars 32 forks source link

Which FastApi version is required ? #4

Closed OlivierPonant closed 2 years ago

OlivierPonant commented 2 years ago

Hi,

I would like to test your module which suits with my needs, but I'm facing out issue with tutorial/sample.py. When I launch this, I get this error:

.\global_venv\lib\site-packages\fastapi_quickcrud\misc\schema_builder.py:263: UserWarning: The column of id has not default value and it is not nullable and in exclude_listit may throw error when you insert data 
  warnings.warn(
Traceback (most recent call last):
  File "./api/run3.py", line 23, in <module>
    crud_route_parent = generic_sql_crud_router_builder(
  File ".\global_venv\lib\site-packages\fastapi_quickcrud\crud_router.py", line 400, in crud_router_builder
    api = APIRouter(**router_kwargs)
TypeError: __init__() got an unexpected keyword argument 'sql_type'

It seems, the parameter sql_type is not expected by the FastApi class APIRouter. I checked quickly this class on FastAPI github, but I found no change for a while, missed I something ?

Best regards,

LuisLuii commented 2 years ago

Hi OlivierPonant, thank you for submitting the issue. The root cause is because generic_sql_crud_router_builder is deprecated method. you can use crud_router_builder instead of generic_sql_crud_router_builder. but these two method are do the same work . generic_sql_crud_router_builder = partial(crud_router_builder)

now it should works after I fixing.

Please uninstall or reinstall the fastapi-quickcrud to use the fixed version library. And Just let me know by telegram as follows if you don't understand for the library. https://t.me/llui1123

btw, thank you very much for helping to identify the problem so that others can use this smoothly in the future

I think I have to update the tutorial for the latest version, and you can read the README as well since it should correct for any detail

LuisLuii commented 2 years ago

It has been found that there is an adaptation problem between the version of starlette > 0.14.2 and asyncpg. If there is no special requirement, it is recommended to use starlette <= 0.14.2 first

FYI https://github.com/encode/starlette/issues/1315