GithubHelp home page GithubHelp logo

Comments (6)

tomchristie avatar tomchristie commented on August 15, 2024 1

Actually it's not obvious if that'd be best or not.

Forcing explicit connection is a good way to ensure correct setup. If we just lazily establish the connection pool, then eg. it's easier to accidentally omit startup/shutdown events when integrating databases with a web framework.

from databases.

tomchristie avatar tomchristie commented on August 15, 2024 1

Anyways let's close this issue off. We're good as we are.

Thanks for the extra feedback on it! 😄

from databases.

vltr avatar vltr commented on August 15, 2024

Just my two cents ...

Forcing explicit connection is a good way to ensure correct setup.

I agree. There was no single async service I made (either using Twisted or "now" with asyncio) that didn't required explicit connection handling in a use cycle ... Of course, you can always use the NullPoll with Postgres behind pgBounce, but not everyone deploys that strategy into production.

There are good patterns to be used out there to handle this, not to mention the @transaction and context managers already implemented to do that in the package. 👍

it's easier to accidentally omit startup/shutdown events when integrating databases with a web framework.

What do you mean? Leave a connection open after the request lifecycle is finished or leave the database open when shutting down the server (assuming it's an asyncio server) ?

from databases.

tomchristie avatar tomchristie commented on August 15, 2024

I mean if we force explicit connects, then it's also more likely that users will remember to use explicit disconnects too.

(If your test cases make sure to startup/shutdown the web application then this ties in nicely with making sure that force_rollback runs at the end of every test case.)

Eg. in Starlette we'd expect users to integrate like so:

@app.on_event('startup')
async def startup():
    await database.connect()

@app.on_event('shutdown')
async def shutdown():
    await database.disconnect()

from databases.

vltr avatar vltr commented on August 15, 2024

The example you gave is exactly what I had in mind (relative to asyncio servers). And no need to thank me, we really need some effort on this (databases, ORMs, etc). I would not say that we (developers) feel "abandoned" in the asyncio database special area, but the ecossystem is really not that rich when it comes to that. I hope this changes in the future 😉

from databases.

Congee avatar Congee commented on August 15, 2024

Is there any existing option to enable lazy loading rather than me implementing it from scratch? 🤔

from databases.

Related Issues (20)

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.