SQLite Forum

Insert ("slurp" ?) JSON documents
Login
My [sqlite-utils CLI tool](https://sqlite-utils.readthedocs.io/en/stable/cli.html#inserting-json-data) can do exactly this:

```
echo '[
    {
        "id": 1,
        "name": "Cleo",
        "age": 4
    },
    {
        "id": 2,
        "name": "Pancakes",
        "age": 2
    },
    {
        "id": 3,
        "name": "Toby",
        "age": 6
    }
]' | sqlite-utils insert dogs.db dogs - --pk=id
```
Having run this a new database file called `dogs.db` will be created with the following schema:

```
$ sqlite3 dogs.db .schema
CREATE TABLE [dogs] (
   [id] INTEGER PRIMARY KEY,
   [name] TEXT,
   [age] INTEGER
);

```