how to dump query results into nt format in virtuoso

This is on ubuntu 14.04 LTS

1. you need to install virtuoso (you can refer to my previous post)

2. open your virtuoso service

3. do

./isql 1111

to invoke the virtuosl‘s isql interface

4. copy and past the following: (source: click me )

/**
 * Dumps the result of the given select-sparql query into a file
 * or a sequence of files based on a file size limit.
 *
 * @param query A select query. Only the first three variables in the projection will be dumped
 * @param out_file A base filename. ‘.nt‘ will be autmatically appended.
 * @param file_length_limit A result set is split to multiple files according to this limit.
 *        If it is greater 0 a sequence number will be appended to the filename.
 */
drop procedure dump_query_nt;
create procedure dump_query_nt(in query varchar, in out_file varchar, in file_length_limit integer := -1)
{
    declare file_name varchar;
    declare env, ses any;
    declare ses_len, max_ses_len, file_len, file_idx integer;
    declare state, msg, descs any;
    declare chandle any;
    declare sub any;
    declare sql any;
    set isolation = ‘uncommitted‘;
    max_ses_len := 10000000;
    file_len := 0;
    file_idx := 1;

    if(file_length_limit >= 0) {
        file_name := sprintf (‘%s-%06d.nt‘, out_file, file_idx);
    } else {
        file_name := sprintf (‘%s.nt‘, out_file);
    }

    string_to_file (file_name || ‘.query‘, query, -2);
    env := vector (0, 0, 0);
    ses := string_output ();

    state := ‘00000‘;
    sql := sprintf(‘sparql define input:storage "" %s‘, query);

    exec(sql, state, msg, vector (), 0, descs, null, chandle);
    if (state <> ‘00000‘) {
        signal (state, msg);
    }

    while(exec_next(chandle, state, msg, sub) = 0) {
        if (state <> ‘00000‘) {
            signal (state, msg);
        }

        http_nt_triple (env, sub[0], sub[1], sub[2], ses);
        ses_len := length (ses);

        if (ses_len > max_ses_len) {
            file_len := file_len + ses_len;
            if (file_length_limit >= 0 and file_len > file_length_limit) {
                string_to_file (file_name, ses, -1);
                file_len := 0;
                file_idx := file_idx + 1;
                file_name := sprintf (‘%s-%06d.nt‘, out_file, file_idx);
                env := vector (0, 0, 0);
            }
            else {
              string_to_file (file_name, ses, -1);
            }

            ses := string_output ();
        }
    }
    if (length (ses)) {
        string_to_file (file_name, ses, -1);
    }

    exec_close(chandle);
};

5. hit enter to regester this dump_query_nt function

6. an example of usage of this function is as follows:

dump_query_nt(‘Select ?s ?p ?o { ?s a ?c . ?s ?p ?o . }‘, ‘/tmp/result‘);

you input this in the prompt, make sure /temp/result directory is accessible for virtuoso. you could go to virtuoso.ini (under certain directory) to config it.

时间: 2024-10-24 23:27:09

how to dump query results into nt format in virtuoso的相关文章

These query results are not updateable.Include the ROWID to get updateable results.

通过plsql来添加新的记录时候,出现如下错误:These query results are not updateable.Include the ROWID to get updateable results. 如截图: 解决办法如下: 第一种解决方案:select* from  T_status_set for update 第二种解决方案:select tss.* ,rowid from  T_status_set tss

File attachment or query results size exceeds allowable value of 1000000 bytes

DECLARE @tab char(1) = CHAR(9) EXEC msdb.dbo.sp_send_dbmail @profile_name = 'backupNotify', @recipients = '[email protected]', @query = 'select cardno,badge,empname,empdep,swptime,macip from CanteenProject.dbo.ADSSwipData where badge like ''T%'' and

oracle 不能更新 PL/SQL 点击“edit data”报“ these query results are not updateable”

你可以选择在查询语句的最后加上 for update,就可以打开编辑锁,直接修改数据. 而在默认查询下,点击Edit data,会报错:The query results are not updateable. SQL代码示例 select * from table_name for update; (table_name为要编辑的表)

laravel路由无法访问,报404,No query results for model [App\Models\...]

今天遇到了一个问题,在routes/web.php中配置了路由,但始终无法访问该路由,一直报404. Route::resource('gift_packs', 'GiftPacksController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]); Route::get('gift_packs/test', '[email protected]')->name('gift_pa

Powershell连接多服务器执行SQL脚本

$query = " select @@servername" $csvFilePath = "c:\Scripts\queryresults.csv"   $instanceNameList = get-content c:\Scripts\serverlist.txt [email protected]()    foreach($instanceName in $instanceNameList) {         write-host "Exec

Save results to different files when executing multi SQL statements in DB Query Analyzer 7.01

1 About DB Query Analyzer DB Query Analyzer is presented by Master Genfeng,Ma from Chinese Mainland. It has English version named 'DB Query Analyzer'and Simplified Chinese version named   . DB Query Analyzer is one of the few excellent Client Tools i

DB Query Analyzer 6.03, the most excellent Universal DB Access tools on any Microsoft Windows OS

?  ?DB Query Analyzer 6.03, the most excellent Universal database Access tools on any Microsoft Windows OS DB Query Analyzer is presented by Master Genfeng, Ma from Chinese Mainland. It has English version named 'DB Query Analyzer' and Simplified Chi

Install and run DB Query Analyzer 6.04 on Microsoft Windows 10

      Install and run DB Query Analyzer 6.04 on Microsoft Windows 10  DB Query Analyzer is presented by Master Genfeng, Ma from Chinese Mainland. It has English version named 'DB Query Analyzer' and Simplified Chinese version named   . DB Query Analy

Result Cache特性之SQL QUERY结果集缓存

在Oracle 11g中,推出了Result Cache新特性,对于结果集合进行缓存处理,减少了IO,提高了性能.服务器端结果集缓存位于共享池中,缓存这SQL query结果,包括sql查询结果.函数结果.OLAP应用程序能够显著受益于服务器端结果集缓存.当然,这个益处有赖于应用程序本身.其中比较好的使用场景就是从一个大表中查询返回小部分数量的结果,比如数据仓库环境.例如,类似于物化视图通过表固化查询结果,结果集缓存也可以让你启用高级查询重写功能. 这一新特性包括三部分: 1)SQL QUERY