begin implementing proper database
This commit is contained in:
parent
2c8a181b1c
commit
a80da909b7
2 changed files with 20 additions and 34 deletions
|
|
@ -1,20 +1,13 @@
|
||||||
package com.mykola2312.mptv;
|
package com.mykola2312.mptv;
|
||||||
|
|
||||||
import com.mykola2312.mptv.config.Config;
|
import com.mykola2312.mptv.config.Config;
|
||||||
import com.mykola2312.mptv.crawler.WebRequest;
|
|
||||||
import com.mykola2312.mptv.db.DB;
|
import com.mykola2312.mptv.db.DB;
|
||||||
import com.mykola2312.mptv.ui.MainFrame;
|
import com.mykola2312.mptv.ui.MainFrame;
|
||||||
import org.apache.commons.cli.*;
|
import org.apache.commons.cli.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.flywaydb.core.Flyway;
|
import org.flywaydb.core.Flyway;
|
||||||
import org.checkerframework.checker.nullness.qual.*;
|
|
||||||
|
|
||||||
import static com.mykola2312.mptv.tables.Test.*;
|
|
||||||
import org.jooq.*;
|
|
||||||
import org.jooq.impl.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static final Logger logger = Logger.getLogger(Main.class);
|
private static final Logger logger = Logger.getLogger(Main.class);
|
||||||
|
|
@ -61,9 +54,6 @@ public class Main {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainFrame frame = new MainFrame();
|
|
||||||
frame.create(config.frame);
|
|
||||||
|
|
||||||
Flyway flyway = new Flyway(
|
Flyway flyway = new Flyway(
|
||||||
Flyway.configure()
|
Flyway.configure()
|
||||||
.dataSource(DB.URL, DB.USER, DB.PASSWORD)
|
.dataSource(DB.URL, DB.USER, DB.PASSWORD)
|
||||||
|
|
@ -72,26 +62,8 @@ public class Main {
|
||||||
);
|
);
|
||||||
flyway.migrate();
|
flyway.migrate();
|
||||||
|
|
||||||
DSLContext create = DSL.using(DB.CONFIG);
|
MainFrame frame = new MainFrame();
|
||||||
@NonNull List<Test> result = create
|
frame.create(config.frame);
|
||||||
.select()
|
|
||||||
.from(TEST)
|
|
||||||
.fetchInto(Test.class);
|
|
||||||
for (Test t : result) {
|
|
||||||
System.out.printf("%d: %s\n", t.id, t.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
create = DSL.using(DB.CONFIG);
|
|
||||||
Test test = create
|
|
||||||
.select()
|
|
||||||
.from(TEST)
|
|
||||||
.limit(1)
|
|
||||||
.fetchOne()
|
|
||||||
.into(Test.class);
|
|
||||||
System.out.printf("fetchOne -> %d: %s\n", test.id, test.value);
|
|
||||||
|
|
||||||
WebRequest get = new WebRequest("https://example.com");
|
|
||||||
System.out.println(get.fetch().body);
|
|
||||||
|
|
||||||
logger.info("mptv started");
|
logger.info("mptv started");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,18 @@
|
||||||
CREATE TABLE test (
|
CREATE TABLE category (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
value TEXT NOT NULL
|
title TEXT NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_category_title ON category(title);
|
||||||
|
|
||||||
|
CREATE TABLE channel (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
category INTEGER NOT NULL,
|
||||||
|
title TEXT NOT NULL,
|
||||||
|
url TEXT NOT NULL,
|
||||||
|
logo TEXT,
|
||||||
|
|
||||||
|
FOREIGN KEY (category) REFERENCES category(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_channel_title ON channel(title);
|
||||||
Loading…
Add table
Reference in a new issue