William,

On 23 Oct 2010, at 19:54, William Waites wrote:

Hi all,

Following up on the previous thread [0] about getting literal
values out of an ODBC connection for SPASQL queries, I've
managed to make a preliminary patch for pyodbc that does this [1].

I noticed two issues when doing this. First, Virtuoso OS 6.1.2
seems to only give the proper datatype values if 'output:valmode "LONG"'
is defined. This is a bit inconvenient because it means extra
select queries to resolve them (albeit cheap ones).

[Hugh] It is unclear as to what the problem is, can you please provide a sample SPARQL query and Dataset to demonstrate the problem ?

The second problem, which my tests in [2] uncovered, where we
put some triples in the store and then check to see if what we
get back is the same, is that for values with xsd:date, I
seem to be getting a dvtype of VIRTUOSO_DV_DATETIME where it
should be VIRTUOSO_DV_DATE.

[Hugh] The attached source file is the module development wrote for our Redland RDF Provider [1], which uses these ODBC extensions, and shows how this can be done:
...
 int dvtype = 0;
 int dv_dt_type = 0;
rc = SQLGetDescField(hdesc, col, SQL_DESC_COL_DV_TYPE, &dvtype, SQL_IS_INTEGER, NULL);
rc = SQLGetDescField(hdesc, col, SQL_DESC_COL_DT_DT_TYPE, &dv_dt_type, SQL_IS_INTEGER, NULL);

if (dvtype == DV_TIMESTAMP ||  dvtype == DV_TIME || dvtype == DV_DATE ||dvtype == DV_DATETIME) {
 switch(dv_dt_type)
           {
           case DT_TYPE_DATE:
             u_type = librdf_new_uri(storage->world,
                 (unsigned char *)"http://www.w3.org/2001/XMLSchema#date");
             break;
           case DT_TYPE_TIME:
             u_type = librdf_new_uri(storage->world,
                 (unsigned char *)"http://www.w3.org/2001/XMLSchema#time");
             break;
    default:
               u_type = librdf_new_uri(storage->world,
               (unsigned char *)"http://www.w3.org/2001/XMLSchema#dateTime");
             break;
           }
         node = librdf_new_node_from_typed_literal(storage->world,
                        (const unsigned char *)data, NULL, u_type);
         break;
  }
}
...

The source file can be used as a reference to see how these extensions can be used ...

Regards
Hugh 


Attachment: rdf_storage_virtuoso.c
Description: Binary data



e.g.:

   AssertionError: Round-trip mismatch:
       (rdflib.term.URIRef('http://example.org/'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#comment'), rdflib.term.Literal(u'2010-10-23', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#date')))
       (rdflib.term.URIRef('http://example.org/'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#comment'), rdflib.term.Literal(u'2010-10-23', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTime')))

There is also the minor nit that perhaps dates would be better
returned in ISO format, e.g. '2010-10-23T20:51:00.602149' instead
of '2010-10-23 20:51:00.602149'. Haven't yet looked at what
happens when timezones are thrown into the mix.

Is all this expected? Is it an error in the documentation that
that doesn't mention the requirement for 'output:valmode "LONG"'
or an error in the server?

Cheers,
-w

[0] http://sourceforge.net/mailarchive/forum.php?thread_name=4C978E4C.90003%40openlinksw.com&forum_name=virtuoso-users
[1] http://river.styx.org/ww/2010/10/pyodbc-spasql/index
[2] http://bitbucket.org/ww/virtuoso/src/tip/virtuoso/tests/test_rdflib3.py

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to