#!/bin/sh ## Feeding CSV as follows: ## user,gecos,email,team # j2100,"HIROSE Yuuji",yuuji@es.gentei.org,Teacher ## This script can be run repeatedly in order to change team allocation. DB=${1:-users.sq3} CSV=${2:-trrusers.csv} sqlite3 ${DB} <<-EOF .mode csv CREATE TEMPORARY TABLE newuser(user, gecos, email, team); .read inittbl.sql .import $CSV newuser DELETE FROM newuser WHERE user LIKE 'user'; INSERT INTO teams SELECT distinct team FROM newuser WHERE team NOT IN (SELECT team FROM teams); PRAGMA foreign_keys=off; -- To avoid score deletion REPLACE INTO users SELECT user, gecos, email, team FROM newuser; EOF