Code Monkey home page Code Monkey logo

Comments (2)

jbruechert avatar jbruechert commented on August 16, 2024 2

For SQLite I have https://invent.KDE.org/libraries/futuresql, which works with QCoro. Although it could be used for other database types, it would be inefficient. It just uses a single thread to run queries, so it doesn't block the GUI, but can't run queries in parallel since it is still based on QtSqls blocking API.

from qcoro.

danvratil avatar danvratil commented on August 16, 2024

Hi, I'm glad to hear that you like QCoro :)

Supporting sql is tricky - this library is designed to wrap existing Qt types and make certain operations awaitable - which is possible thanks to most relevant Qt classes providing an async API already (you call some method and eventually the object will emit a signal that it's done), which is trivial to wrap into an awaitable wrapper.

Unfortunately, QtSql is completely synchronous (QSqlQuery::exec() blocks until the database engine is done). The only option would be to move the query to an another thread, execute it there and then asynchronously wait for the thread to finish. This is, however, much more complicated than just wrapping an existing Qt type into an awaitable - there could be unintended or unexpected consequences of moving the query between threads. So instead, I'd have to write a custom equivalent of QSqlQuery or even a completely custom SQL "drivers" using native asynchronous APIs of mysql or postgres, which would be a non-trivial amount of work to write and maintain, and would almost certainly be a separate library v from QCoro.

That said, I initially started exploring coroutines exactly to see how SQL could be done asynchronously and I do have a use case for it myself. So I'm not saying it ain't gonna happen, just likely won't happen any time soon, sorry.

from qcoro.

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.