I'm using SQLite for desktop applications, but in Rust it requires C wrapper that not native dependency.
Thoughts, maybe some modern alternative available?
Finally what do I want from the database:
storage in single file (at user profile directory)
transactions
foreign or just primary keys relations
async API would be good also (I/O data on background of the main UI thread)
If there is nothing better than SQLite yet, which of crates would be useful?
Also thoughts how to implement migrations from app version to version.. maybe I need some ORM wrapper, not sure. Please advice, how do you work with profile data in Rust these days
Despite SQLite being written in C, it is very high quality code, and it will not be easy to replicate that kind of project for anyone, in any language. That includes the original author btw, since at this point literal decades of work have gone into SQLite.
In addition to it being high quality, it is also very much battle-tested: it is used e.g. in Android, as a storage backend for apps, in Firefox and Thunderbird, in many Apple products, in Windows 10, and many more places.
Just as a general headsup: You likely want to avoid any async SQLite interfaces. Those come with a large performance penalty, as they try to emulate an async interface on top of the sync sqlite C API. See here for numbers.
Other than that: It's usually not a good choice to use libsqlite3-sys directly as that are the low level bindings to the c library. You should prefer rusqlite instead, which provides a high level API build on top of libsqlite3-sys
Thanks, both solutions looks interesting, especially redb for simple key/value storage - bookmarked so. Currently selected rusqlite, even can't say it is really high-level wrapper, especially in selection context, maybe will switch to sqlx later or diesel as supports migrations from the box.
It might also not be a bad idea to check out Apache DataFusion.
It's written in Rust, has FFI to eg Python, and as a project it's kind of like a Swiss army knife for tabular data, or alternatively, "what if we pull apart a DB into its constituent parts and offer those as a library?".
We're using it at $WORK and all things considered I'm pretty impressed by what it can do.
As usual it's not guaranteed that it would actually be better than SQLite. C is much worse language but if you compare amount of effort that went into SQLite and compare it to a new project that's only a few months old… I wouldn't try to build anything on top of it just yet… but would keep an eye on their progress.
Found PoloDB - not SQL, not key/value but looks pretty useful and clear in examples. It also supports transactions, not sure about multi-thread context, so let's maybe try.
UPD. seems it requires librocksdb dependency, that means not 'native' solution (#195)
Compiling polodb-librocksdb-sys v9.0.0-alpha.1
error: failed to run custom build command for `polodb-librocksdb-sys v9.0.0-alpha.1`
UPD 2. not sure yet, but surrealdb project looks interesting also