This project implements
- A process to convert relational databases to property graph databases.
- A process to translate SQL queries to Cypher queries by parsing, tokenizing SQL queries and converting SQL queries to Cypher queries.
- Rel2Graph: Automated Mapping From Relational Databases to a Unified Property Knowledge Graph.
The main requirements are:
- Python 3.6+
- Neo4J Community Edition
We recommend using virtual environments to run this code:
python -m virtualenv venv
source venv\bin\activate
Python packages can be installed via:
git clone git@github.com:nlp-tlp/Rel2Graph.git
pip install torch torchvision
python3 -m pip install -r requirements.txt
or
pip install -r requirements.txt
Text-to-Spider benchmarks, e.g., Spider, KaggleDBQA, and BIRD. We use the Spider and KaggleDBQA benchmarks to illustrate the process.
Take Spider as an example, firstly download the pre-processed data release, and unzip the folder. Then, put the data into rel_db2kg/data/spider
.
Note: If you would like to preprocess Spider dataset by yourself, please refer to salesforce TabularSemanticParsing
-
Setting the
config.ini
file.- Create an
.env
file.
GRAPH_PASSWORD=<your-neo4j-password>
- The application that will be run, are determined in the
config.ini
file:
[FILENAMES] root = <path-to->/Rel2Graph benchmark = Spider neo4j_import_folder = <path-to->/neo4j-community-4.4.11/import> neo4j_uri = http://localhost:7474/browser/ neo4j_user = neo4j neo4j_password = <your-neo4j-password>
- Meanwhile, please config Neo4j export path.
cd ConverDB.py
Set
_neo4j_export_path = '<path-to->/neo4j-community-4.4.11/import'
inClass ConvertDB
. - Create an
-
Configure
conf/db.ini
filespider_path = <path-to->/Rel2Graph/data/spider/database database = musical [neo4j] port = 7687 host = localhost username = neo4j password = <your-neo4j-password>
-
Running Neo4j
cd <path-to-neo4j-bin> ./neo4j start
-
Constructing a property graph database from any arbitrary relational database schemas directly.
cd rel_db2kg python schema2graph.py --<benchmark_dataset-name> --cased
Translate SQL queries to Cypher queries.
cd rel_db2kg python sql2cypher.py
-
Running interface
python interface --web_ui
If you find the resource in this repository helpful, please cite
https://arxiv.org/abs/2310.01080
If you are interested in our work, please feel free to contact Ziyu Zhao Email: ziyu.zhao@research.uwa.edu.au