On 18/09/2010 17:40, William Waites wrote:
> (1) check that the database is Virtuoso,
> (2) check that the query was SPASQL (3) pre-emptively
> go and collect type information before returning each
> row.
> 
> Is there a straightforward way to do (1) and (2) at all?

Hi,

pyodbc supports SQLGetInfo():

> In [35]: import pyodbc
> 
> In [36]: conn=pyodbc.connect("DSN=virtdiscussion")
> 
> In [37]: conn.getinfo(pyodbc.SQL_DBMS_NAME)
> Out[37]: 'OpenLink Virtuoso'

Presumably the obvious way to check a query for SPASQL is to see if the
first word in the query is "sparql":

> In [38]: import re
> 
> In [39]: re.search("^\s*sparql ", "SPARQL select distinct * where { ?s ?p ?o 
> . };", re.I)
> Out[39]: <_sre.SRE_Match object at 0x1053d55e0>
> 
> In [40]: type(re.search("^\s*sparql ", "select distinct * where { ?s ?p ?o . 
> };"))
> Out[41]: <type 'NoneType'>

HTH,

~Tim
-- 
Tim Haynes
Product Development Consultant
OpenLink Software
<http://www.openlinksw.com/>
<http://twitter.com/openlink>

Reply via email to