Welcome to r2rml4net, a project which brings R2RML to the .NET world.
The preferred way to use r2rml4net is by its CLI, installed a a dotnet tool package
dotnet tool install -g r2rml4net-cli
Alternatively, the library r2rml4net
NuGet package can be installed and used from code.
The default command is to process a mapping graph against an SQL database to produce quad data. The CLI requires a standard .NET connection string and a path to the R2RML mappings. The path can be a single RDF file or a directory, in which case all direct children will be loaded.
r2rml4net \
-c "Server=SQLEXPRESS;Database=Northwind;User Id=myUsername;Password=myPassword;" \
-m "./mappings/"
Without additional parameters the resulting data will be streamed to the standard output as n-quads.
For full help run r2rml4net rml --help
It is also possible to perform a direct mapping of the source database using a generated default mapping.
In this mode only the connection string is required.
r2rml4net direct -c "Server=SQLEXPRESS;Database=Northwind;User Id=myUsername;Password=myPassword;"
Similarly, without additional parameters the resulting data will be streamed to the standard output as n-triples.
For full help run r2rml4net direct --help
Finally, a default mapping document can be generated. It will be printed to standard output as turtle.
r2rml4net default-mapping -c "Server=SQLEXPRESS;Database=Northwind;User Id=myUsername;Password=myPassword;"
A -o, --output
option can be used to write the resulting dataset using a quad serialization chosen by the file extension (.nq
, .trig
, .trix
or .jsonld
).
r2rml4net \
-c "Server=SQLEXPRESS;Database=Northwind;User Id=myUsername;Password=myPassword;" \
-m "./mappings/" \
-o data.trig
WARNING The file is not streamed and the entire dataset is kept in memory saved once the processing finishes. For large datasets it's better to pipe the output directly or write to SPARQL endpoint.
Generated quads can be inserted into a SPARQL endpoint in batches.
r2rml4net \
-c "Server=SQLEXPRESS;Database=Northwind;User Id=myUsername;Password=myPassword;" \
-e "http://example.com/sparql" \
--user admin \
--pass pass \
-batch-size 2500
Only the -e, --endpoint
parameter is required.
A base URI can be provided with -b, --base-uri
to all commands. The same base will be used when generating the default mapping, parsing mapping documents as well as generating triples.
A --preserve-duplicate-rows
flag can be used with r2rml4net direct
to generate multiple subjects for tables without primary keys.
See the specification for details.
As of version 0.7 r2rml4net:
- Built as .NET Core App 2.2 (CLI) and .NET Standard 2.0 (library)
- Is nearly fully compatible with the R2RML specifications,
- Can load existing R2RML mapping graphs from any RDF serialization,
- Can creating R2RML graphs programmatically using a fluent API,
- Can generate R2RML graphs from relational databases (aka Direct Mapping),
- Can convert data from relational databases to structured data,
- Has been tested and supports Microsoft SQL Server.
- Support for other database managements systems