We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
You can use the Dgraph migration tool to convert a MySQL database tables into a schema and RDF file, and then load the resulting dataset into Dgraph.
Before converting the data, the migration tool needs to derive the schema of each predicate. Dgraph follows two simple rules for converting the schema:
Body
column in the
Posts
table is of type text
, and hence, the predicate posts.Body
is of
type string
: posts.Body: string .
posts.OwnerUserId.
, simply have the type [uid]
, meaning following the
predicate leads us to a set of other objects.You can run the Dgraph migrate tool using this command:
Create a config.properties
file that has the following settings and values
shouldn’t be in quotes:
Export the SQL database into schema.txt
and sql.rdf
file:
An output similar to this appears:
If you are connecting to a remote DB hosted on AWS, Google Cloud, and others,
you need to pass the flags --host
, and --port
. For description of the
various flags in the migration tool, see command line
options.
After the migration is complete, two new files are available:
sql.rdf
containing all the N-Quad entriesschema.txt
.The two files can then be imported into Dgraph using the
Dgraph Live Loader or
Bulk Loader. Sometimes you might want to customize
your schema. For example, you might add an index to a predicate, or change an
inter-object predicate (edge) from unidirectional to bidirectional by adding the
@reverse
directive. If you would like such customizations, you should do it by
editing the schema file generated by the migration tool before feeding the files
to the Live Loader or Bulk Loader.
To import the data into Dgraph using the Live Loader to Dgraph Zero and Alpha servers running on the default ports use:
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
You can use the Dgraph migration tool to convert a MySQL database tables into a schema and RDF file, and then load the resulting dataset into Dgraph.
Before converting the data, the migration tool needs to derive the schema of each predicate. Dgraph follows two simple rules for converting the schema:
Body
column in the
Posts
table is of type text
, and hence, the predicate posts.Body
is of
type string
: posts.Body: string .
posts.OwnerUserId.
, simply have the type [uid]
, meaning following the
predicate leads us to a set of other objects.You can run the Dgraph migrate tool using this command:
Create a config.properties
file that has the following settings and values
shouldn’t be in quotes:
Export the SQL database into schema.txt
and sql.rdf
file:
An output similar to this appears:
If you are connecting to a remote DB hosted on AWS, Google Cloud, and others,
you need to pass the flags --host
, and --port
. For description of the
various flags in the migration tool, see command line
options.
After the migration is complete, two new files are available:
sql.rdf
containing all the N-Quad entriesschema.txt
.The two files can then be imported into Dgraph using the
Dgraph Live Loader or
Bulk Loader. Sometimes you might want to customize
your schema. For example, you might add an index to a predicate, or change an
inter-object predicate (edge) from unidirectional to bidirectional by adding the
@reverse
directive. If you would like such customizations, you should do it by
editing the schema file generated by the migration tool before feeding the files
to the Live Loader or Bulk Loader.
To import the data into Dgraph using the Live Loader to Dgraph Zero and Alpha servers running on the default ports use: