Giter Site home page Giter Site logo

Comments (10)

LuisLuii avatar LuisLuii commented on May 23, 2024

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.

LuisLuii avatar LuisLuii commented on May 23, 2024

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.

LuisLuii avatar LuisLuii commented on May 23, 2024

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.

filipmarkoski avatar filipmarkoski commented on May 23, 2024
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.

filipmarkoski avatar filipmarkoski commented on May 23, 2024

Here's a GitHub repository with all of the code.
https://github.com/filipmarkoski/fastapi-learning

from fastapiquickcrud.

filipmarkoski avatar filipmarkoski commented on May 23, 2024

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.

filipmarkoski avatar filipmarkoski commented on May 23, 2024

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.

LuisLuii avatar LuisLuii commented on May 23, 2024

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.

LuisLuii avatar LuisLuii commented on May 23, 2024

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.

LuisLuii avatar LuisLuii commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.