Skip to content

Importing Project Data

Tim Andres edited this page Mar 12, 2014 · 1 revision

DM allows you to import RDF project data into its datastore via the rdf_import management command.

If you are running your DM instance at a non-root URL, i.e. anything other than "/", you will need to run this management command with slightly modified settings. This is because DM's named RDF graphs are stored using URIs generated by Django's URL reversing features, which only include the base of the URL when being run via a WSGI server (not via command line or shell tools). Your modified settings file should look something like this:

from settings import * # Import all of your base settings, including local settings defined in settings_local.py

# Force the URI generators in DM to use the proper base URI
FORCE_SCRIPT_NAME = '/your_base_uri'
URI_MINT_BASE = 'http://dm.drew.edu/your_base_uri'

You can call this settings file something like settings_rdf_import.py, and then run management commands with --settings=settings_rdf_import to use it. You should also use this settings file if you want to view or manipulate RDF graphs via the shell management command.

The rdf_import management command can accept either a single file or a directory of files using either the -f of -d flags respectively. These files can be in any RDF format which Python's RDFLib can read, e.g. .rdf, .xml, .n3, .ttl, etc. They must be formatted as DM Projects (see the DM Project Format Wiki Page). If you haven't included any user permissions data in the project which you imported, you can grant ownership of the project to an existing user using the grant_full_project_permissions management command with a -u flag for the username and a -p flag for the project's uri. The project should then be visible to that user from within the DM interface.

Example usage:

python manage.py rdf_import -f ~/path/to/my/file.n3 --settings=settings_rdf_import

Clone this wiki locally