1
0
Fork 0

Revert "Revert "Begin add diesel""

This reverts commit e4e39fa0a9.
This commit is contained in:
Florian RICHER 2023-01-02 21:22:18 +01:00
parent e4e39fa0a9
commit 135c84109f
16 changed files with 184 additions and 7 deletions

3
.env
View file

@ -1 +1,2 @@
URL=https://vk.gy/database
URL=https://vk.gy/database
DATABASE_URL=sqlite://db.sqlite

1
.gitignore vendored
View file

@ -1 +1,2 @@
/target
*.sqlite

71
Cargo.lock generated
View file

@ -103,6 +103,7 @@ dependencies = [
name = "data_extractor"
version = "0.1.0"
dependencies = [
"diesel",
"dotenvy",
"reqwest",
"scraper",
@ -121,6 +122,28 @@ dependencies = [
"syn",
]
[[package]]
name = "diesel"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68c186a7418a2aac330bb76cde82f16c36b03a66fb91db32d20214311f9f6545"
dependencies = [
"diesel_derives",
"libsqlite3-sys",
]
[[package]]
name = "diesel_derives"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "143b758c91dbc3fe1fdcb0dba5bd13276c6a66422f2ef5795b58488248a310aa"
dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "dirs"
version = "4.0.0"
@ -506,6 +529,16 @@ version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libsqlite3-sys"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29f835d03d717946d28b1d1ed632eb6f0e24a299388ee623d0c23118d3e8a7fa"
dependencies = [
"pkg-config",
"vcpkg",
]
[[package]]
name = "lock_api"
version = "0.4.7"
@ -817,6 +850,30 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
@ -1021,9 +1078,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scraper"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5684396b456f3eb69ceeb34d1b5cb1a2f6acf7ca4452131efa3ba0ee2c2d0a70"
checksum = "fc7cb4dae083699a22a65aa9d2699c27f525e35dffaec38b10801e958ed4cf27"
dependencies = [
"cssparser",
"ego-tree",
@ -1137,9 +1194,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "smallvec"
version = "1.8.0"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "socket2"
@ -1384,6 +1441,12 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "want"
version = "0.3.0"

View file

@ -7,5 +7,6 @@ edition = "2021"
[dependencies]
reqwest = {version = "0.11", features = ["blocking"]}
scraper = "0.13.0"
dotenvy = "0.15.1"
scraper = "0.14.0"
dotenvy = "0.15.1"
diesel = { version = "2.0.2", features = ["sqlite"] }

3
README.md Normal file
View file

@ -0,0 +1,3 @@
cargo install diesel_cli --no-default-features --features sqlite
~/.cargo/bin/diesel setup

8
diesel.toml Normal file
View file

@ -0,0 +1,8 @@
# For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli
[print_schema]
file = "src/schema.rs"
[migrations_directory]
dir = "migrations"

0
migrations/.keep Normal file
View file

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE artists

View file

@ -0,0 +1,9 @@
-- Your SQL goes here
CREATE TABLE artists (
id INTEGER PRIMARY KEY AUTOINCREMENT,
artist_name VARCHAR NOT NULL,
artist_url VARCHAR NOT NULL,
date INT NOT NULL,
author VARCHAR NOT NULL,
author_url VARCHAR NOT NULL
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE labels

View file

@ -0,0 +1,9 @@
-- Your SQL goes here
CREATE TABLE labels (
id INTEGER PRIMARY KEY AUTOINCREMENT,
artist_name VARCHAR NOT NULL,
artist_url VARCHAR NOT NULL,
date INT NOT NULL,
author VARCHAR NOT NULL,
author_url VARCHAR NOT NULL
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE musicians

View file

@ -0,0 +1,9 @@
-- Your SQL goes here
CREATE TABLE musicians (
id INTEGER PRIMARY KEY AUTOINCREMENT,
artist_name VARCHAR NOT NULL,
artist_url VARCHAR NOT NULL,
date INT NOT NULL,
author VARCHAR NOT NULL,
author_url VARCHAR NOT NULL
)

View file

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
DROP TABLE releases

View file

@ -0,0 +1,11 @@
-- Your SQL goes here
CREATE TABLE releases (
id INTEGER PRIMARY KEY AUTOINCREMENT,
artist_name VARCHAR NOT NULL,
artist_url VARCHAR NOT NULL,
album VARCHAR NOT NULL,
album_url VARCHAR NOT NULL,
date INT NOT NULL,
author VARCHAR NOT NULL,
author_url VARCHAR NOT NULL
)

54
src/schema.rs Normal file
View file

@ -0,0 +1,54 @@
// @generated automatically by Diesel CLI.
diesel::table! {
artists (id) {
id -> Nullable<Integer>,
artist_name -> Text,
artist_url -> Text,
date -> Integer,
author -> Text,
author_url -> Text,
}
}
diesel::table! {
labels (id) {
id -> Nullable<Integer>,
artist_name -> Text,
artist_url -> Text,
date -> Integer,
author -> Text,
author_url -> Text,
}
}
diesel::table! {
musicians (id) {
id -> Nullable<Integer>,
artist_name -> Text,
artist_url -> Text,
date -> Integer,
author -> Text,
author_url -> Text,
}
}
diesel::table! {
releases (id) {
id -> Nullable<Integer>,
artist_name -> Text,
artist_url -> Text,
album -> Text,
album_url -> Text,
date -> Integer,
author -> Text,
author_url -> Text,
}
}
diesel::allow_tables_to_appear_in_same_query!(
artists,
labels,
musicians,
releases,
);