Comments (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.
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)
- `CheckAtomic.cmake` Fails on Windows with LLVM Clang
- Build Failure with Clang `15.x`< on Windows in Debug
- QCoroSignal crashes
- QCoro::waitFor does not rethrow exceptions
- Add latest Qt6 to CI
- Bind coroutine to a QObject lifetime HOT 6
- Make not co_awaiting a coroutine trigger -Wunused-result HOT 1
- Add this library to vcpkg HOT 1
- Apple Clang ICEs in Release build of QCoro HOT 1
- Update QCoro in ConanCenter
- Next release HOT 3
- ASSERT: "this->mAwaitedCoroutine != nullptr" when awaiting a default-constructed Task HOT 4
- like winrt HOT 2
- support mqtt HOT 2
- Qt Design Studio : Mocking QCoro::QmlTask in Javascript or QML HOT 3
- Clang 14.x ornery about std::experimental::coroutine_traits HOT 3
- Illogical result of the `write` function.
- Bug: application crashes when signal from another thread timeouts HOT 1
- Support for move only types in QFuture via takeResult
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 qcoro.