jobscraper/db/jobstest.db.sql

53 lines
1.3 KiB
MySQL
Raw Normal View History

2020-05-25 09:21:56 +00:00
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "jobs" (
"_id" INTEGER NOT NULL UNIQUE,
"title" TEXT,
"site" TEXT,
"url" TEXT,
"id" TEXT UNIQUE,
"summary" TEXT,
"company" TEXT,
"location" TEXT,
"postdate" TEXT,
"salary" TEXT,
"easyapply" INTEGER,
"timestamp" INTEGER,
PRIMARY KEY("_id" AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS "read" (
"_id" INTEGER NOT NULL UNIQUE,
"rid" INTEGER UNIQUE,
"d" INTEGER NOT NULL,
2020-05-25 13:51:52 +00:00
PRIMARY KEY("_id" AUTOINCREMENT),
FOREIGN KEY("rid") REFERENCES "jobs"("_id")
);
CREATE TABLE IF NOT EXISTS "applied" (
"_id" INTEGER NOT NULL UNIQUE,
"aid" INTEGER UNIQUE,
"a" INTEGER NOT NULL,
PRIMARY KEY("_id" AUTOINCREMENT),
FOREIGN KEY("aid") REFERENCES "jobs"("_id")
2020-05-25 09:21:56 +00:00
);
2020-05-25 13:51:52 +00:00
DROP VIEW IF EXISTS "jobsList";
2020-05-25 09:21:56 +00:00
CREATE VIEW jobsList as
2020-05-25 13:51:52 +00:00
select jobs._id, jobs.title, jobs.site, jobs.company, jobs.timestamp, read.d, applied.a from jobs
2020-05-25 09:21:56 +00:00
left join read on read.rid = jobs._id
2020-05-25 13:51:52 +00:00
left join applied on applied.aid = jobs._id
2020-05-25 09:21:56 +00:00
order by jobs._id desc;
2020-06-01 08:13:04 +00:00
DROP TABLE IF EXISTS "accounts";
CREATE TABLE IF NOT EXISTS "accounts" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
"email" TEXT NOT NULL
);
INSERT INTO accounts VALUES(1,'bob','plop','bob@plop.com');
INSERT INTO accounts VALUES(2,'martin','MPReoa43','martind2000@gmail.com');
INSERT INTO sqlite_sequence VALUES('accounts',2);
2020-05-25 09:21:56 +00:00
COMMIT;