-1

I am using Virtuoso engine. For entering a query into Virtuoso engine, the following needs to be done:

The virtuoso engine starts and gives the command prompt:

[myMachine]$ ./isql 1111 
Connected to OpenLink Virtuoso
Driver: 07.20.3213 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL> 

The query "sparql select ?a?b?c where{graph ?g{?a ?b ?c} };" is entered by the user as following:

[myMachine]$ ./isql 1111 
Connected to OpenLink Virtuoso
Driver: 07.20.3213 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL> sparql select ?a?b?c where{graph ?g{?a ?b ?c} };

Now in order to automate the process of inserting queries into Virtuoso I wrote the user entered value:"sparql select ?a?b?c where{graph ?g{?a ?b ?c} };" into a text file (mytext.txt) and used the following command:

[myMachine]$ ./isql 1111 < mytext.txt

However still the Virtuoso prompt appears as the following -- asking me to enter the query string:

[myMachine]$ ./isql 1111 < mytext.txt
Connected to OpenLink Virtuoso
Driver: 07.20.3213 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL> 

Is there some way in linux or c++: by which using shell script (for linux) or system calls for c++ I can enter my query string into Virtuoso. I need to run 10,000 queries therefore manually entering 10,000 queries in Virtuoso is a pain.

(Question also asked on Virtuoso support forum.)

TallTed
  • 9,069
  • 2
  • 22
  • 37
Steg Verner
  • 893
  • 2
  • 12
  • 28

2 Answers2

1

The manpage for isql is quite clear:

isql can be used to submit SQL to a data source and to format/output results. It can be used in batch or interactive mode.

And:

-b      Batch mode. It will not do any prompting.

Which is exactly what you want, no?

[myMachine]$ ./isql 1111 -b < mytext.txt

Slightly confusing is that there is an example of piping data to isql even without -b:

cat My.sql | isql WebDB MyID MyPWD -w
Each line in My.sql must contain exactly 1 SQL command except for the last line which must be blank.


Disclaimer: I have no idea what OpenLink Virtuoso is or does; I'm just performing reading comprehension for you.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
1

There are multiple ways you might script interactions with Virtuoso (produced by my employer, OpenLink Software), both involving iSQL and not.

Depending on the specific queries you're running, and what you plan to do with the results, some approaches might be better than others -- such as using curl with SPARQL query request URIs that include data serialization instructions (e.g., CSV, Turtle, TriG) for the resulting output file. There's not enough information here to know which direction to pursue.

StackOverflow is not usually the best place for product-specific, non-programming questions. Virtuoso-specific questions are usually best raised to the Virtuoso Users mailing list, the public OpenLink Software Support forums, or a confidential Support Case.

TallTed
  • 9,069
  • 2
  • 22
  • 37