Skip to content

Instantly share code, notes, and snippets.

View danielhmills's full-sized avatar

Daniel Heward-Mills danielhmills

View GitHub Profile
### TURTLE START ###
PREFIX : <https://help.twitter.com/en/using-twitter/cotweets#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
:cotweet
a schema:Question;
rdfs:label """What’s a CoTweet?"""^^xsd:string;
schema:acceptedAnswer :cotweet-answer.
@danielhmills
danielhmills / rdf_collection_demo_1.ttl
Last active June 8, 2022 19:31
RDF Collection Demo: Trip
## Turtle Start ##
@prefix: <#>.
:A :route ([:to :B; :distance 50] );
:route ([:to :C; :distance 50]);
:route ([:to :D; :distance 20]).
:C a :Place;
:route ([:to :E; :distance 20] ).
@danielhmills
danielhmills / gist:45cf502a5929c8268e094837dfa0505a
Created July 30, 2021 05:04
Cleansing Date Column w/ DATATYPE()
SELECT *
WHERE
{
?s dbp:birthDate ?birth.
FILTER(DATATYPE(?birth) = xsd:date)
}
LIMIT 10
input {
jdbc {
jdbc_driver_library => "/path_to_virtuoso_jdbc_driver/virtjdbc4.jar"
jdbc_driver_class => "Java::virtuoso.jdbc4.Driver"
jdbc_connection_string => "jdbc:virtuoso://localhost:1111"
jdbc_user => "{Username}"
jdbc_password => "{Password}"
#SPARQL-Within-SQL Example
statement => "SELECT CAST(X.s as varchar) AS test FROM (SPARQL SELECT ?s WHERE {?s ?p ?o} LIMIT 10) as X"
[Local Virtuoso Demo PyODBC]
Driver = /opt/virtuoso/lib/virtodbcu_r.so
Address = localhost:21118
PWDClearText = 0
LastUser = dba
DayLight = Yes
RoundRobin = No
NoSystemTables = No
TreatViewsAsTables = No
WideAsUTF16 = Yes
SPARQL
SELECT *
WHERE
{
SERVICE <https://yyour-neptune-instance.ct2pgivua9wd.us-east-1.neptune.amazonaws.com:8182/sparql>
{
?s ?p ?o
}
}
LIMIT 1
import pyodbc as db
q = "SELECT * FROM demo..company"
cnxn = db.connect("DSN=Demo DB;UID=vdb;PWD=vdb")
cursor=cnxn.cursor()
cursor.execute(q)
row=cursor.fetchall()
if row:
print(row)
SELECT * FROM demo.dbpedia.company
CREATE VIEW demo.dbpedia.company
AS
(
SPARQL
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
SELECT *
WHERE
{
?company dbp:type <http://dbpedia.org/resource/Public_company>;
rdfs:label ?companyName;
dbo:industry dbr:Automobile;
dbo:product/rdfs:label ?product.
FILTER(lang(?companyName)= 'en' && lang(?product) = 'en').
}