A tool for converting Wikidata dumps to a SurrealDB database. Either From a bz2 or json file.
Find a file
2023-12-18 04:10:54 -08:00
.cargo init 2023-12-13 01:04:51 +00:00
.devcontainer init 2023-12-13 01:04:51 +00:00
.github/workflows tests 2023-12-17 20:49:29 -08:00
.vscode mulit line json 2023-12-13 15:20:48 -08:00
src more error handling and overwrite option 2023-12-18 04:10:54 -08:00
tests more error handling and overwrite option 2023-12-18 04:10:54 -08:00
.dockerignore progress bar, fix docker 2023-12-16 00:35:55 -08:00
.gitignore bz2 2023-12-15 06:47:29 +00:00
Cargo.toml more error handling and overwrite option 2023-12-18 04:10:54 -08:00
CONTRIBUTING.md more error handling and overwrite option 2023-12-18 04:10:54 -08:00
docker-compose.dev.yml more error handling and overwrite option 2023-12-18 04:10:54 -08:00
docker-compose.yml more error handling and overwrite option 2023-12-18 04:10:54 -08:00
Dockerfile tests 2023-12-17 20:49:29 -08:00
LICENSE-Apache init 2023-12-13 01:04:51 +00:00
LICENSE-MIT init 2023-12-13 01:04:51 +00:00
README.md more error handling and overwrite option 2023-12-18 04:10:54 -08:00
Useful queries.md tests 2023-12-17 20:49:29 -08:00

Wikidata to SurrealDB

A tool for converting Wikidata dumps to a SurrealDB database. Either From a bz2 or json file.

Getting The Data

https://www.wikidata.org/wiki/Wikidata:Data_access

From bz2 file ~80GB

Dump: Docs

Download - latest-all.json.bz2

From json file

Linked Data Interface: Docs

https://www.wikidata.org/wiki/Special:EntityData/Q60746544.json
https://www.wikidata.org/wiki/Special:EntityData/P527.json

Install

Copy docker-compose.yml

Create data folder next to docker-compose.yml and .env, place data inside, and set the data type in .env

├── data
│   ├── Entity.json
│   ├── latest-all.json.bz2
│   └── surrealdb
├── docker-compose.yml
└── .env

docker compose up --pull always

Example .env

DB_USER=root
DB_PASSWORD=root
WIKIDATA_LANG=en
FILE_FORMAT=bz2
FILE_NAME=data/latest-all.json.bz2
# If not using docker file for Wikidata to SurrealDB, use 0.0.0.0:8000
WIKIDATA_DB_PORT=surrealdb:8000
THREADED_REQUESTS=true
# true=overwrite existing data, false=skip if already exists
OVERWRITE_DB=false

View Progress

docker attach wikidata-to-surrealdb

Dev Install

How to Query

See Useful queries.md

Table Schema

SurrealDB Thing

pub struct Thing {
    pub table: String,
    pub id: Id, // i64
}

Tables: Entity, Property, Lexeme

pub struct EntityMini {
    pub id: Option<Thing>,
    pub label: String,
     // Claims Table
    pub claims: Thing,
    pub description: String,
}

Table: Claims

pub struct Claim {
    pub id: Thing,
    pub value: ClaimData,
}

ClaimData

pub enum ClaimData {
    // Entity, Property, Lexeme Tables
    Thing(Thing), 
    ClaimValueData(ClaimValueData),
}

Docs for ClaimValueData

Similar Projects

License

All code in this repository is dual-licensed under either License-MIT or LICENSE-APACHE at your option. This means you can select the license you prefer. Why dual license.