summaryrefslogtreecommitdiffstats
path: root/generation/query.sh
blob: a6a9783ed179f123f533f1392ba8607d662014b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

if [[ "$1" != "" ]]; then
  # format YYYY-MM-DD, e.g. 2017-01-01
  DATE_PART="AND joined_at > strftime('%s', '$1')"
fi

SQL=`cat <<EOF
SELECT id,firstname,lastname FROM users
LEFT JOIN authentication ON users.id = authentication.user
WHERE (users.disabled IS NULL or users.disabled != 1)
AND id > 0
$DATE_PART
EOF
`
sqlite3 shop.db "$SQL" \
  | sed "s~|~,~g" > users.csv