Virtuoso RDF Bulk Loader — isql loader generation from a source folder
Generate a ready-to-run isql .sql from a local folder of RDF files. Two modes:
| Mode | Mechanism | Use for |
|---|---|---|
dir (default) | ld_dir + rdf_loader_run — one named graph for the whole folder; Virtuoso auto-detects format (N-Triples, Turtle, RDF/XML, N-Quads, TriG, JSON-LD, Notation3) and reads gzip/bzip2 natively | Simple bulk ingestion, mixed formats, compressed archives |
per-file | TTLP_MT — one named graph per file (Turtle family: .ttl, .nt, .trig), optional auto prefix-preamble and CLEAR-before-load | Exact per-document graphs (e.g. an agent memory store), re-loadable deltas |
Workflow
- Elicit (never guess): source folder (must be accessible to the Virtuoso server process —
ld_dirregisters server-side paths), target graph IRI (dir mode), file pattern or format list. - Generate:
bash
python3 scripts/generate-bulk-load-sql.py \ --source-dir /path/to/rdf/ \ --graph https://example.com/my-graph \ --pattern '*.ttl' \ --out bulk-load.sql - Run (your credentials, never displayed):
bash
isql 1111 dba <dba-password> -f bulk-load.sql - Monitor (the generated script ends with the load_list check):
sql
select * from db.dba.load_list where ll_state <> 2;ll_state 2= done; rows remaining = still pending/errored (ll_errorcolumn). - Verify (generated script ends with per-graph counts):
sql
SPARQL SELECT ?g (COUNT(*) AS ?t) WHERE { GRAPH ?g { ?s ?p ?o } } GROUP BY ?g;
Options (generate-bulk-load-sql.py)
| Flag | Default | Meaning |
|---|---|---|
--source-dir | (required) | Folder containing the RDF files (server-visible path) |
--graph | urn:dav:/DAV/home/kidehen/bulk-load/ | Target named graph (dir mode) |
--pattern | *.* | ld_dir pattern, e.g. *.ttl, *.nt.gz, *.nq |
--formats | — | Shorthand expanding to patterns, e.g. ttl,nt,nq |
--mode | dir | dir (ld_dir) or per-file (TTLP_MT per document) |
--graph-base | urn:dav:/DAV/home/kidehen/bulk-load/ | IRI prefix for per-file graphs (file relpath appended) |
--preamble | off | per-file mode: prepend store-wide prefix union so prefix-undeclared Turtle loads |
--clear | off | Emit SPARQL CLEAR GRAPH before loading (idempotent re-runs) |
--out | bulk-load.sql | Output path |
--dry-run | off | Print the script instead of writing |
Notes
- Server-side paths:
ld_dirpaths are read by the Virtuoso server, not your client. For a remote Virtuoso, stage files on the server first. - Idempotency:
ld_dirdoes not double-load identical files;rdf_loader_run()may be re-run safely.--clearmakes full re-runs replace the graph. - Troubleshooting: load failures, permission issues, DAV paths, and named-graph management — see the
virtuoso-rdf-loaderskill (ld_dir + rdf_loader_run deep-dive). - This skill is the generator generalization of the agent-rdf-memory loader (
agent-rdf-memory/scripts/generate-loader-sql.py); that store'srefresh-loader.shis the same pattern in action.
Safe Virtuoso ISQL Error Output
Whenever this workflow invokes OpenLink's native Virtuoso isql client, pass the bare client option COMMAND_TEXT_ON_ERROR=OFF, for example isql {host}:{port} {user} {password} COMMAND_TEXT_ON_ERROR=OFF {script.sql}. Place it before SQL input, script arguments, or -i. OFF maps to the client's internal value 0 and prevents the client from appending the full failed command to error output. The client accepts OFF/ON; literal 0 is rejected. Do not use -u for this setting (-u populates the U argument array). This does not redact secrets from server diagnostics, shell history, or process arguments, so keep credentials out of SQL text and logs. Do not apply this Virtuoso-specific option to unixODBC/iODBC isql clients.


