Comments (9)
Hi could you share some infomation to let me reproduce your issue? such as the SQLalchemy schema, and the code
from fastapiquickcrud.
Hi Luis, I've been using the User
Model from the first demo.
class User(Base):
__tablename__ = 'test_users'
id = Column(Integer, primary_key=True, autoincrement=True, unique=True)
name = Column(String, nullable=False)
email = Column(String, nullable=False)
crud_route_1 = crud_router_builder(db_model=User,
prefix="/user",
tags=["User"],
db_session=session,
sql_type=SqlType("postgresql"),
# async_mode=True
)
app = FastAPI()
app.include_router(crud_route_1)
Initially I thought it was due to an environment clash, as I was using Conda with pip dependencies, however the issue seems to persist when the versions are pinned to those in the Readme, and even with only fastapi-quickcrud
in the environment.
I've tried recreating your "Simple Code" example in another file, and even with only fastapi-quickcrud
in the environment the issue seems to be there. The only changes I made were to point at a postrgess database, with
db_session=session,
sql_type=SqlType("postgresql"),
from fastapiquickcrud.
many thanks Antony, I still no idea about the local_kw , btw could you run that normally without set the session like the following example, which is using in-memory db
https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/tutorial/sample.py
or could you share your full code that includes the session part of code.
from fastapiquickcrud.
Hi Luis,
Running the example at https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/tutorial/sample.py
works fine, so I'll use that for now :)
from fastapiquickcrud.
Looking back to postures integration, it seems that the local_kw
appears when we add the following lines to our model
db_session=async_session,
sql_type=SqlType("postgresql"),
e.g. from:
crud_route_child = generic_sql_crud_router_builder(
db_model=Child,
prefix="/child",
tags=["child"],
)
to :
crud_route_child = generic_sql_crud_router_builder(
db_model=Child,
prefix="/child",
tags=["child"],
db_session=async_session,
sql_type=SqlType("postgresql"),
)
for reference, the async session is:
engine = create_engine("postgresql://xxxx:[email protected]/xxxxx")
session = sessionmaker(engine)
async_session = sessionmaker(
autocommit=False,
autoflush=False,
bind=engine,
)
from fastapiquickcrud.
Thanks Antony! I have reproduced it based on your information. And It is due to my documentation is not clear enough.
I saw you has used the async_session to be db_session argument. The correct way is like the following
engine = create_engine("postgresql://xxxx:[email protected]/xxxxx")
session = sessionmaker(engine)
def get_transaction_session():
try:
db = session()
yield db
finally:
db.close()
crud_route_child = generic_sql_crud_router_builder(
db_model=Child,
prefix="/child",
tags=["child"],
db_session= get_transaction_session,
sql_type=SqlType("postgresql"),
)
from fastapiquickcrud.
I am facing almost the same issue, I am also seeing local_kw in one of my api endpoint, any specific solution ?
from fastapiquickcrud.
The changes Luis suggested in #20 (comment) worked fine for me. And I've been using the libraries without issues
from fastapiquickcrud.
The changes Luis suggested in #20 (comment) worked fine for me. And I've been using the libraries without issues
Hi Avin, sorry for reply so late, so happy to see you are using it fine. I will suggest u to try my another crud code generator project. Which one is optimised on query and able to maintain by yourself. I have used it in few project already and working so far so good.
from fastapiquickcrud.
Related Issues (14)
- Postgres SqlAlchemy model with server defaults and different schema cannot be used HOT 10
- New feature discussion HOT 2
- Support for PostgreSQL data types HOT 2
- fix case insensitive in sqlite
- How to run the FastAPIQuickCRUD is NOT Clear HOT 33
- pip install error HOT 2
- should we move some deps to dev deps? HOT 1
- required field on update api should follow table setting, not all required
- Bump major deps HOT 3
- Which FastApi version is required ? HOT 2
- Docs page cannot open HOT 1
- Suggestion HOT 6
- Use tree-like API for foreign keys. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapiquickcrud.