A non-blocking database framework for Qt.
FutureSQL was in part inspired by Diesel, and provides a higher level of abstraction than QtSql. Its features include non-blocking database access by default, relatively boilderplate-free queries, automatic database migrations and simple mapping to objects.
In order to make FutureSQL's use of templates less confusing, FutureSQL uses C++20 concepts, and requires a C++20 compiler.
Warning: The API is not finalized yet.
The following example demonstrates the usage of FutureSQL in conjunction with QCoro:
In code were coroutines don't make sense, you can use
QCoro::connect of QCoro > v0.8.0, or
QFuture<T>::then() on Qt6, to run a callback once a database query finished.
FutureSQL can manage database migrations in a way that is mostly compatible with diesel. You just need to pass it a directory (preferably in QRC) that contains migrations in the following format:
Naming the migration directories after dates is a good practice, as the migrations are run in sorted order. Naming them for example by a counting number would break once the numbers get to large. For example, if you don't use leading zeros and only one digit, you'd only have up to 10 migrations.
The migration directory structure can be generated by the
diesel command line tool. You can install it using cargo as follows:
Finally, you can run the migrations from your C++ code: