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;
|
||||
|
||||
import com.mykola2312.mptv.config.Config;
|
||||
import com.mykola2312.mptv.crawler.WebRequest;
|
||||
import com.mykola2312.mptv.db.DB;
|
||||
import com.mykola2312.mptv.ui.MainFrame;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.log4j.Logger;
|
||||
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.util.List;
|
||||
|
||||
public class Main {
|
||||
private static final Logger logger = Logger.getLogger(Main.class);
|
||||
|
|
@ -61,9 +54,6 @@ public class Main {
|
|||
return;
|
||||
}
|
||||
|
||||
MainFrame frame = new MainFrame();
|
||||
frame.create(config.frame);
|
||||
|
||||
Flyway flyway = new Flyway(
|
||||
Flyway.configure()
|
||||
.dataSource(DB.URL, DB.USER, DB.PASSWORD)
|
||||
|
|
@ -72,26 +62,8 @@ public class Main {
|
|||
);
|
||||
flyway.migrate();
|
||||
|
||||
DSLContext create = DSL.using(DB.CONFIG);
|
||||
@NonNull List<Test> result = create
|
||||
.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);
|
||||
MainFrame frame = new MainFrame();
|
||||
frame.create(config.frame);
|
||||
|
||||
logger.info("mptv started");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,18 @@
|
|||
CREATE TABLE test (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE category (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
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