-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed_data.sql
More file actions
11 lines (9 loc) · 774 Bytes
/
seed_data.sql
File metadata and controls
11 lines (9 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
COPY students FROM '/Users/davidgaither/Projects/flask_postgres_school/data/student.csv' DELIMITER ',' CSV HEADER;
COPY subjects FROM '/Users/davidgaither/Projects/flask_postgres_school/data/subjects.csv' DELIMITER ',' CSV HEADER;
COPY teachers FROM '/Users/davidgaither/Projects/flask_postgres_school/data/teachers.csv' DELIMITER ',' CSV HEADER;
-- Because we've inserted rows with hardcoded values for the primary key, id
-- the sequence used to generate id values for new rows is stuck at "1". So
-- we manually reset the sequences to the max value of id for each table.
SELECT setval('students_id_seq', (SELECT MAX(id) FROM students));
SELECT setval('subjects_id_seq', (SELECT MAX(id) FROM subjects));
SELECT setval('teachers_id_seq', (SELECT MAX(id) FROM teachers));