The details of how the data is stored are described in this 1979 paper by Douglas Comer: "The Ubiquitous B-Tree" [1]. Since it was invented, much hasn't really changed: practically all relational databases use some variation of this structure. I wrote about it in [2], which might help explain some aspects of how it works.
A lot of modern databases don't use Btrees anymore. With a LSM structure you can use other suitable data structures because they can be write-only. For example leveldb uses a simple binary search.
[1] https://dl.acm.org/doi/10.1145/356770.356776
[2] https://grisha.org/blog/2013/05/11/relational-database-on-to...
Edit: also [3] is about how to store SQLite in a Redis hash (rather than on-disk file).
[3] https://grisha.org/blog/2013/05/29/sqlite-db-stored-in-a-red...