pyLodStorage 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/PKG-INFO +1 -1
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/sql.py +20 -5
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/trulytabular.py +9 -2
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/version.py +2 -2
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/pylodstorage.egg-info/PKG-INFO +1 -1
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/endpoints.yaml +37 -1
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/queries.yaml +3 -2
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/trulytabular.yaml +1 -1
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/LICENSE +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/README.md +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/csv.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/entity.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/jsonable.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/lod.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/plot.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/query.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/querymain.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/sample.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/schema.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/storageconfig.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/uml.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/pylodstorage.egg-info/entry_points.txt +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/__init__.py +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/formats.yaml +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/scholia.yaml +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/wf.yaml +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/sampledata/wikidata.yaml +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/setup.cfg +0 -0
- {pylodstorage-0.2.0 → pylodstorage-0.2.2}/setup.py +0 -0
|
@@ -173,9 +173,9 @@ class SQLDB(object):
|
|
|
173
173
|
msg="%s\nfailed:%s%s" % (insertCmd,str(ex),debugInfo)
|
|
174
174
|
raise Exception(msg)
|
|
175
175
|
|
|
176
|
-
def
|
|
176
|
+
def queryGen(self,sqlQuery,params=None):
|
|
177
177
|
'''
|
|
178
|
-
run the given sqlQuery
|
|
178
|
+
run the given sqlQuery a a generator for dicts
|
|
179
179
|
|
|
180
180
|
Args:
|
|
181
181
|
|
|
@@ -183,7 +183,7 @@ class SQLDB(object):
|
|
|
183
183
|
params(tuple): the query params, if any
|
|
184
184
|
|
|
185
185
|
Returns:
|
|
186
|
-
|
|
186
|
+
a generator of dicts
|
|
187
187
|
'''
|
|
188
188
|
if self.debug:
|
|
189
189
|
print(sqlQuery)
|
|
@@ -196,17 +196,32 @@ class SQLDB(object):
|
|
|
196
196
|
else:
|
|
197
197
|
query = cur.execute(sqlQuery)
|
|
198
198
|
colname = [ d[0] for d in query.description ]
|
|
199
|
-
resultList=[]
|
|
200
199
|
try:
|
|
201
200
|
# loop over all rows
|
|
202
201
|
for row in query:
|
|
203
202
|
record=dict(zip(colname, row))
|
|
204
|
-
|
|
203
|
+
yield record
|
|
205
204
|
except Exception as ex:
|
|
206
205
|
msg=str(ex)
|
|
207
206
|
self.logError(msg)
|
|
208
207
|
pass
|
|
209
208
|
cur.close()
|
|
209
|
+
|
|
210
|
+
def query(self,sqlQuery,params=None):
|
|
211
|
+
'''
|
|
212
|
+
run the given sqlQuery and return a list of Dicts
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
|
|
216
|
+
sqlQuery(string): the SQL query to be executed
|
|
217
|
+
params(tuple): the query params, if any
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
list: a list of Dicts
|
|
221
|
+
'''
|
|
222
|
+
resultList=[]
|
|
223
|
+
for record in self.queryGen(sqlQuery, params):
|
|
224
|
+
resultList.append(record)
|
|
210
225
|
return resultList
|
|
211
226
|
|
|
212
227
|
def queryAll(self,entityInfo,fixDates=True):
|
|
@@ -323,13 +323,20 @@ WHERE
|
|
|
323
323
|
return qm
|
|
324
324
|
return None
|
|
325
325
|
|
|
326
|
-
def mostFrequentPropertiesQuery(self):
|
|
326
|
+
def mostFrequentPropertiesQuery(self,whereClause:str=None):
|
|
327
327
|
'''
|
|
328
328
|
get the most frequently used properties
|
|
329
|
+
|
|
330
|
+
Args:
|
|
331
|
+
whereClause(str): an extra WhereClause to use
|
|
329
332
|
'''
|
|
330
333
|
query=self.queryManager.queriesByName["mostFrequentProperties"]
|
|
334
|
+
if whereClause is None:
|
|
335
|
+
whereClause=f"?item wdt:P31 wd:{self.itemQid};";
|
|
336
|
+
else:
|
|
337
|
+
whereClause+=";"
|
|
331
338
|
query.title=f"most frequently used properties for {self.asText(long=True)}"
|
|
332
|
-
query.query=query.query % (self.item.asText(long=True),
|
|
339
|
+
query.query=query.query % (self.item.asText(long=True),whereClause,self.lang)
|
|
333
340
|
return query
|
|
334
341
|
|
|
335
342
|
def noneTabularQuery(self,wdProperty:WikidataProperty,asFrequency:bool=True):
|
|
@@ -109,4 +109,40 @@
|
|
|
109
109
|
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
|
|
110
110
|
PREFIX wdv: <http://www.wikidata.org/value/>
|
|
111
111
|
PREFIX wikibase: <http://wikiba.se/ontology#>
|
|
112
|
-
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
112
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
113
|
+
'wikidata-openlinksw':
|
|
114
|
+
lang: sparql
|
|
115
|
+
endpoint: https://wikidata.demo.openlinksw.com/sparql
|
|
116
|
+
prefixes: |
|
|
117
|
+
PREFIX bd: <http://www.bigdata.com/rdf#>
|
|
118
|
+
PREFIX cc: <http://creativecommons.org/ns#>
|
|
119
|
+
PREFIX dct: <http://purl.org/dc/terms/>
|
|
120
|
+
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
|
|
121
|
+
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
|
|
122
|
+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
|
123
|
+
PREFIX p: <http://www.wikidata.org/prop/>
|
|
124
|
+
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
|
|
125
|
+
PREFIX pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/>
|
|
126
|
+
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
|
|
127
|
+
PREFIX pr: <http://www.wikidata.org/prop/reference/>
|
|
128
|
+
PREFIX prn: <http://www.wikidata.org/prop/reference/value-normalized/>
|
|
129
|
+
PREFIX prov: <http://www.w3.org/ns/prov#>
|
|
130
|
+
PREFIX prv: <http://www.
|
|
131
|
+
wikidata.org/prop/reference/value/>
|
|
132
|
+
PREFIX ps: <http://www.wikidata.org/prop/statement/>
|
|
133
|
+
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
|
|
134
|
+
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
|
|
135
|
+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
136
|
+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
137
|
+
PREFIX schema: <http://schema.org/>
|
|
138
|
+
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
139
|
+
PREFIX wd: <http://www.wikidata.org/entity/>
|
|
140
|
+
PREFIX wdata: <http://www.wikidata.org/wiki/Special:EntityData/>
|
|
141
|
+
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
|
|
142
|
+
PREFIX wdref: <http://www.wikidata.org/reference/>
|
|
143
|
+
PREFIX wds: <http://www.wikidata.org/entity/statement/>
|
|
144
|
+
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
|
|
145
|
+
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
|
|
146
|
+
PREFIX wdv: <http://www.wikidata.org/value/>
|
|
147
|
+
PREFIX wikibase: <http://wikiba.se/ontology#>
|
|
148
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
@@ -87,8 +87,9 @@
|
|
|
87
87
|
# president
|
|
88
88
|
?president wdt:P39 wd:Q11696.
|
|
89
89
|
# nickname
|
|
90
|
-
?president wdt:P1449 ?nickName
|
|
91
|
-
|
|
90
|
+
?president wdt:P1449 ?nickName.
|
|
91
|
+
?president rdfs:label ?presidentLabel.
|
|
92
|
+
FILTER (LANG(?presidentLabel)="en")
|
|
92
93
|
} GROUP BY ?president ?presidentLabel
|
|
93
94
|
title: Nick names of US Presidents
|
|
94
95
|
tryItUrl: https://query.wikidata.org
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|