Skip to content

Commit e77d5b3

Browse files
authored
Syntax highlighting in README
1 parent a597deb commit e77d5b3

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

README.md

+26-23
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,31 @@ The repository at [simonw/simonwillisonblog-backup](https://github.com/simonw/si
1717
## Dumping a database
1818

1919
Given a SQLite database called `fixtures.db` containing a table `facetable`, the following will dump out that table to the `dump/` directory:
20-
21-
sqlite-diffable dump fixtures.db dump/ facetable
22-
20+
```bash
21+
sqlite-diffable dump fixtures.db dump/ facetable
22+
```
2323
To dump out every table in that database, use `--all`:
24-
25-
sqlite-diffable dump fixtures.db dump/ --all
26-
24+
```bash
25+
sqlite-diffable dump fixtures.db dump/ --all
26+
```
2727
To dump all table except some specific ones, use `--exclude` one or more times:
28-
29-
sqlite-diffable dump fixtures.db dump/ --all --exclude unwanted_first_table --exclude unwanted_second_table
30-
28+
```bash
29+
sqlite-diffable dump fixtures.db dump/ --all \
30+
--exclude unwanted_first_table \
31+
--exclude unwanted_second_table
32+
```
3133
## Loading a database
3234

3335
To load a previously dumped database, run the following:
34-
35-
sqlite-diffable load restored.db dump/
36-
36+
```bash
37+
sqlite-diffable load restored.db dump/
38+
```
3739
This will show an error if any of the tables that are being restored already exist in the database file.
3840

3941
You can replace those tables (dropping them before restoring them) using the `--replace` option:
40-
41-
sqlite-diffable load restored.db dump/ --replace
42-
42+
```bash
43+
sqlite-diffable load restored.db dump/ --replace
44+
```
4345
## Converting to JSON objects
4446

4547
Table rows are stored in the `.ndjson` files as newline-delimited JSON arrays, like this:
@@ -52,22 +54,23 @@ Table rows are stored in the `.ndjson` files as newline-delimited JSON arrays, l
5254
Sometimes it can be more convenient to work with a list of JSON objects.
5355

5456
The `sqlite-diffable objects` command can read a `.ndjson` file and its accompanying `.metadata.json` file and output JSON objects to standard output:
55-
56-
sqlite-diffable objects fixtures.db dump/sortable.ndjson
57-
57+
```bash
58+
sqlite-diffable objects fixtures.db dump/sortable.ndjson
59+
```
5860
The output of that command looks something like this:
5961
```
6062
{"pk1": "a", "pk2": "a", "content": "a-a", "sortable": 63, "sortable_with_nulls": null, "sortable_with_nulls_2": 0.7364712141640124, "text": "$null"}
6163
{"pk1": "a", "pk2": "b", "content": "a-b", "sortable": 51, "sortable_with_nulls": null, "sortable_with_nulls_2": 0.6020187290499803, "text": "$null"}
6264
```
6365

6466
Add `-o` to write that output to a file:
65-
66-
sqlite-diffable objects fixtures.db dump/sortable.ndjson -o output.txt
67-
67+
```bash
68+
sqlite-diffable objects fixtures.db dump/sortable.ndjson -o output.txt
69+
```
6870
Add `--array` to output a JSON array of objects, as opposed to a newline-delimited file:
69-
70-
sqlite-diffable objects fixtures.db dump/sortable.ndjson --array
71+
```bash
72+
sqlite-diffable objects fixtures.db dump/sortable.ndjson --array
73+
```
7174
Output:
7275
```
7376
[

0 commit comments

Comments
 (0)