Iām very interested in this because RDBMS are my main world. As I have say here, I repeat some points but with better elaboration, I hope:
- Async. Rust is NOT async, and async will be forever, a second-class citizen. If a lang is not async from the start, async dependent libraries are pain. Is good to have async optional., but not force it. I donāt know if wrapping async to be sync work well and not make even more complicated the debugging, so if exist a clean way to use async under the hood is ok to me. BTW, I have use dozen of languages, NONE with async/first db layer and never have hit a real performance problem. This is much more niche (ie: truly need async for performance) that most people think, IMHO.
- We need something like the python database api. If extended for async, fine to me.
- We need a good way to map database results to structs. But despite being type safe is nice, having a HashMap like container is also required. Sql is dynamic and not amount of structs and types will be enough.
- Making full ORM or heavy interfaces like diesel are nice, but is not what we must build first.
- Making query builders and similar is nice, but not depend on it. Send sql strings with parameters. End
- Make nice to do parametrized queries
I wanna to make clear why this is very important. A ātype safeā database layer is good, so much that Iām building a relational language to map more cleanly to RDBMS, BUT, a developer need to setup a lot before start reading/writing to the DB. This assumes you are doing a project for the long run, and truly can type all the schema before running the app.
But building scripts/ETLs, building database REPLs (like psql), UIs, creating something like Django (that need to introspect the db) and much, much more things, you canāt know all before start. Send sql, get results, introspect and move is much more common than have a fixed set of what the schema is.
Is ironic, but SQL is schema less. Tables are fixed, yes, but all the rest is not!
-
Is important to support dates, decimals, enumerations, and embebed data like arrays/json
-
Look how some micro-arm are made (like dapper). I think them hit the sweet spot
-
The library must be integrated with logging
-
Convert from/to json, cvs, etc is not necessary to be on the library. BUT convert to SQL is! (ie: dump sql scripts)
-
Is necessary to provide ways to know the types, sizes, constraints, etc of the sql I have send, the db and the rest.
The #1 sin most commit when talking in how interface with RDBMS/SQL is to hate sql, and try to go full ORM on it. That have been proved, conclusively, to be a mistake, a pipe dream alike cross-platforms UIs. I donāt denied is possible to be close to the ideal, but exist a lot of tradeoffs that IMHO are not to be made on the fundamental layers of this core apis. Let others build on TOP of this.
This cascade in a lot of details. For example @Fiedzia say āmigrations without writing your sqlā.
How you migrate the addition of an extension on PostgreSQL? Or the removal of 10 tables, to be put on one that need a massive SQL rewrite on the middle? āNot write SQLā is nice for BASIC stuff. But if we are talking about sql, sql must be a first class citizen of the APIs.
Put on top any you want.
A 2-layer or 3-layer design can work well (1 layer: Dynamic, sql strings, parameters, 2- SqlAlchemy alike DSL for automating the SQL stuff, 3-Full ORM/Django style)