Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Update SQLite database atomically
Browse files Browse the repository at this point in the history
Otherwise Datasette hits transient errors because either the file
doesn't exist (after the initial rm) or one of the tables doesn't yet
exist.
  • Loading branch information
tsibley committed Jun 10, 2020
1 parent 7f62b11 commit de07e5c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ SHELL := bash -euo pipefail
.PHONY: data/scan-redcap.sqlite

data/scan-redcap.sqlite: data/record-barcodes.ndjson derived-tables.sql
rm -vf $@
sqlite-utils insert --nl $@ record_barcodes $<
sqlite3 $@ < derived-tables.sql
sqlite-utils insert --nl $@.new record_barcodes $<
sqlite3 $@.new < derived-tables.sql
mv -vf $@.new $@

data/record-barcodes.ndjson:
./bin/export-record-barcodes > $@

0 comments on commit de07e5c

Please sign in to comment.