|
|
|
|
|
by simonw
1494 days ago
|
|
> The idea here is that instead of manually creating schemas, what if the schemas were automatically created for you? When something doesn’t fit in a table, how about automatically adding columns for the missing fields? I've been experimenting with this approach against SQLite for a few years now, and I really like it. My sqlite-utils package does exactly this. Try running this on the command line: brew install sqlite-utils
echo '[
{"id": 1, "name": "Cleo"},
{"id": 2, "name": "Azy", "age": 1.5}
]' | sqlite-utils insert /tmp/demo.db creatures - --pk id
sqlite-utils schema /tmp/demo.db
It outputs the generated schema: CREATE TABLE [creatures] (
[id] INTEGER PRIMARY KEY,
[name] TEXT,
[age] FLOAT
);
When you insert more data you can use the --alter flag to have it automatically create any missing columns.Full documentation here: https://sqlite-utils.datasette.io/en/stable/cli.html#inserti... It's also available as a Python library: https://sqlite-utils.datasette.io/en/stable/python-api.html |
|
I'm all for layers, a fundamental approach in our field to tame complexity. And the SQL model and SQLite have stood the test of time and are solid foundations.
I'm just wondering could we be stuck in a local maximum where the presumed answer is always the relational model? Maybe if we built the relational model on top of a different set of lower-level primitives (a type system instead of schemas and tables) we could escape local maximum we're stuck in? Just a thought.
There are a few somewhat ad hoc perf measurements here regarding the sqlite-utils and sqlite... https://zed.brimdata.io/docs/commands/zq/#73-performance-com...
I'm not a SQLite expert so if I did something wrong, please holler and let me know :)