usergraphtheory's picture
Sync from erdostack/bench at a7805c45d77258d316383c92bdc9f472498d255f (part 58)
1e5b853 verified
Raw History Blame Contribute Delete
562 Bytes
#!/bin/sh
# Rebuild data/social.db from data/csv (removes the old file).
set -eu
rm -f data/social.db
docker compose run --rm -T sql /data/social.db <<'SQL'
.read /sql/schema.sql
.mode csv
.import --skip 1 /data/csv/person.csv person
.import --skip 1 /data/csv/person_knows_person.csv person_knows_person
CREATE TEMP TABLE message_in(id, kind, creator_id, reply_of_id, content, creation_date);
.import --skip 1 /data/csv/message.csv message_in
INSERT INTO message SELECT id, kind, creator_id, NULLIF(reply_of_id, ''), content, creation_date FROM message_in;
SQL