Replacing Complicated Hashmaps with SQLite
husin.dev
husin.dev
Just be careful with `:memory:` databases. From the mattn/go-sqlite3 FAQ[1]:
> Each connection to ":memory:" opens a brand new in-memory sql database, so if the stdlib's sql engine happens to open another connection and you've only specified ":memory:", that connection will see a brand new database. A workaround is to use "file::memory:?cache=shared" (or "file:foobar?mode=memory&cache=shared"). Every connection to this string will point to the same in-memory database.
I noticed strange behaviors with just `:memory:` where tables would disappear at random, and this workaround helped. Make sure to use a unique filename as the `file:` value, especially if using this in tests.
I agree with the key-value store too — there are some instances where I wish for a columnar database, but settling to use SQLite with key-value store ended up pretty okay.
I agree; queries are why table semantics are so useful. Whether you choose an SQL implementation (e.g., DuckDB and SQLite) or a dataframe library (e.g., pandas and polars), expressing searches, joins, and aggregations becomes trivial for tabular data.
Kinda thinking a lot of rest APIs could just be SQL logic.
Postgrest is pretty much like that but I wonder if you could build a more general tool. SQL + protobufs or SQL + OpenAPI schema.
But I was more thinking of allowing people to choose any db and be able to expose a rest API on top of that.
Postgres, bigquery, supabase whatever.
So you can quickly deploy a public facing rest API on views from that data.
But I was more thinking any database. And you still get to define/control a public REST interface.
However I had more of a slightly diff idea.
More like instead of having aweb server + orm.
You just write SQL for an endpoint which maps the storage data to public response.
Essentially what the ORM was doing. And if the server is just managing connection and calling then endpoint query. Then packing the data to JSON response. It can just be shared/generic.
https://www.tinybird.co/ is pretty close to this.
Except I'm not sure if they are read only or not.