Comments (10)
I have tested in my environment with your same code with pg version 14 but different AsyncSession generator, and it can run normally and call the api successfully.
Can I have your DATABASE_URL and AsyncSession generator code please?
from fastapiquickcrud.
please try to update the library version to 0.1.9.
I have provided the sql_type
argument in crud_router_builder in this version.
can you please try rerun the code with the code as follows?
from fastapi_quickcrud.misc.type import SqlType
QuoteCRUDRouter = crud_router_builder(db_model=Quote,
prefix='/quote', tags=['Quote'],
exclude_columns=['UUID','DateCreated','DateModified','IsActive'],
crud_methods=[CrudMethods.CREATE_ONE],
async_mode=True,
autocommit=False,
db_session=get_transaction_session,
sql_type=SqlType.postgresql
)
from fastapiquickcrud.
and I hope you can provide more detail of your environment to let me reproduce this issue, such as python version, pip list. Thanks so much
from fastapiquickcrud.
DATABASE_URL = 'postgresql+asyncpg://postgres:metamars@localhost:5432/postgres'
engine = create_async_engine(DATABASE_URL,
future=True, echo=True,
pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200
)
async_session_maker = sessionmaker(engine, class_=AsyncSession,
expire_on_commit=False)
Base: DeclarativeMeta = declarative_base()
async def get_transaction_session() -> AsyncSession:
async with async_session_maker() as session:
async with session.begin():
yield session
I will make a GitHub repository to share all of my code.
from fastapiquickcrud.
Here's a GitHub repository with all of the code.
https://github.com/filipmarkoski/fastapi-learning
from fastapiquickcrud.
Also, is there a way to override a certain function, for example, let's say I want to create an instance of a certain model such as Quote, but I also want to perform some machine learning before I insert the record into the database. Is there any way to get the generated code verbatim, which I can edit how I choose afterwards?
My question is inspired by the following package:
https://pypi.org/project/sqlacodegen/
from fastapiquickcrud.
Your update seemed to work, I am able to post a quote from Swagger now. Thank you! I love the package by the way.
from fastapiquickcrud.
Originally I didn't plan to open sql_type because I wanted to automate it. But it seems like some errors will occur. I'll look into it. Thanks for the issue that made me aware of the bug <3
from fastapiquickcrud.
Also, is there a way to override a certain function, for example, let's say I want to create an instance of a certain model such as Quote, but I also want to perform some machine learning before I insert the record into the database. Is there any way to get the generated code verbatim, which I can edit how I choose afterwards?
My question is inspired by the following package:
https://pypi.org/project/sqlacodegen/
Sorry, it's not supported yet. But this is what I've always wanted to achieve, I think this feature is a high priority, I will implement it after I complete the #9 .
from fastapiquickcrud.
Root cause: Fastapi project in async mode with auto-reload and crud_router_builder with async mode, but I created an event loop to get the type of the sql connection. Which creates multiple event loops when reload.
SOLVED: Provide sql_type to be declared by the user
from fastapiquickcrud.
Related Issues (12)
- New feature discussion HOT 2
- Support for PostgreSQL data types HOT 2
- fix case insensitive in sqlite
- Extraneous `local_kw` added to mandatory arguments in swagger HOT 9
- 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
- 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.