-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathloadCSVs.sql
27 lines (24 loc) · 892 Bytes
/
loadCSVs.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- Usage: Use the -f flag to specify a psql file to run
-- For instance, `psql -h localhost -d database -f loadCSVs.sql
DROP TABLE IF EXISTS public.library_link;
CREATE TABLE public.library_link (
id integer NOT NULL,
value text NOT NULL
);
\copy public.library_link FROM 'links.csv' DELIMITER ',' CSV HEADER;
DROP TABLE IF EXISTS public.library_tokenrecord;
CREATE TABLE public.library_tokenrecord (
id integer NOT NULL,
token text NOT NULL,
source_id integer NOT NULL,
index integer NOT NULL
);
\copy public.library_tokenrecord FROM 'tokens.csv' DELIMITER ',' CSV HEADER;
DROP TABLE IF EXISTS public.library_functionrecord;
CREATE TABLE public.library_functionrecord (
id integer NOT NULL,
text text NOT NULL,
source_id integer NOT NULL,
index integer NOT NULL
);
\copy public.library_functionrecord FROM 'functions.csv' DELIMITER ',' CSV HEADER;