GithubHelp home page GithubHelp logo

shotishu / sql2graph Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redapple/sql2graph

0.0 2.0 0.0 130 KB

helper module to export data from a relational database to a graph database (through CSV files)

License: MIT License

sql2graph's Introduction

sql2graph

sql2graph is a python helper module to export CSV dumps from a relational database to a format that can be imported into a graph database.

Currently, only Neo4J batch-import format is supported. (see https://github.com/jexp/batch-import)

Instructions for Neo4J batch-import

References:

Prerequisites:

  1. Export your SQL tables data as TAB-delimited CSV with fieldnames as first row. For example, using Postgresql, running something like this should work:

    COPY (SELECT * FROM mytable) TO stdout CSV HEADER DELIMITER E'\t';

You can then redirect the output to a file from the psql command line, or you can replace "stdout" above by a file path directly

  1. Copy and rename sql2graph.conf.default to sql2graph.conf (or something else) and edit it. Set the dump filenames for all entities you want to import Optionally, define some index files.

  2. Copy and rename example-export.py script and define the schema for the Nodes and their relations. If you want to index some fields for your entities, don't forget to add "index=True" on them See examples folder.

Then run:

python xyz-export.py --config sql2graph.conf -N nodes.csv -R relations.csv
  1. You should now have:
  • a CSV file representing all nodes for all entities (nodes.csv if you ran the command above)
  • a CSV file representing the relations (relations.csv if you ran the command above)
  • depending on the field indexes you defined, a number of node index files for Neo4J (relation indexes not supported)

(See https://github.com/jexp/batch-import for the various files and format details.)

Stop neo4j before running batch-import.

You have 2 options:

  • either run Neo4J batch-import manually supplying your files on the command line (again, see https://github.com/jexp/batch-import on how to do that)

  • or, run run_batchimport.py which uses the config file to run the command for you (check your sql2graph.conf BATCHIMPORT_SETTINGS section)

    python run_batchimport.py --config sql2graph.conf

  1. (Re)start neo4j

sql2graph's People

Contributors

redapple avatar

Watchers

James Cloos avatar shotishu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.