Feature Request: Support for Synchronous Database Sessions
Is your feature request related to a problem?
No, this is a new feature proposal.
Proposed Solution
I'd like to discuss options for integrating support for synchronous database sessions. I'm open to implementing this myself, but I'd appreciate opinions on the best approach. Here are some potential solutions I've considered:
-
Separate Synchronous Classes
- Create new
SyncFastCrud class and sync_crud_router instance
- Drawback: This would introduce significant code redundancy
-
Dual Function Approach (Similar to Langchain)
- Introduce separate functions for sync and async operations
- Example:
create for sync and acreate for async
- Implementation: Check if the passed db is a
Session or AsyncSession
-
Artificial Session Wrapper
- Create a wrapper to convert sync
Sessions into AsyncSessions
- Use
run_in_threadpool (which FastAPI would do internally for the previous two proposals)
I'm open to other ideas and would appreciate any feedback or alternative suggestions.
Feature Request: Support for Synchronous Database Sessions
Is your feature request related to a problem?
No, this is a new feature proposal.
Proposed Solution
I'd like to discuss options for integrating support for synchronous database sessions. I'm open to implementing this myself, but I'd appreciate opinions on the best approach. Here are some potential solutions I've considered:
Separate Synchronous Classes
SyncFastCrudclass andsync_crud_routerinstanceDual Function Approach (Similar to Langchain)
createfor sync andacreatefor asyncSessionorAsyncSessionArtificial Session Wrapper
Sessions intoAsyncSessionsrun_in_threadpool(which FastAPI would do internally for the previous two proposals)I'm open to other ideas and would appreciate any feedback or alternative suggestions.