pyLodStorage 0.4.7__tar.gz → 0.4.9__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.4.7/pylodstorage.egg-info → pylodstorage-0.4.9}/PKG-INFO +1 -1
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/entity.py +7 -6
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/sql.py +10 -5
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/version.py +2 -2
- {pylodstorage-0.4.7 → pylodstorage-0.4.9/pylodstorage.egg-info}/PKG-INFO +1 -1
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/queries.yaml +16 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/LICENSE +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/README.md +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/csv.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/jsonable.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/lod.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/plot.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/query.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/querymain.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/sample.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/schema.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/storageconfig.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/trulytabular.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/uml.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/xml.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/pylodstorage.egg-info/entry_points.txt +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/__init__.py +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/endpoints.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/formats.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/got.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/scholia.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/trulytabular.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/wf.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/sampledata/wikidata.yaml +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/setup.cfg +0 -0
- {pylodstorage-0.4.7 → pylodstorage-0.4.9}/setup.py +0 -0
|
@@ -290,7 +290,7 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
|
|
|
290
290
|
lod.append(entity.__dict__)
|
|
291
291
|
return lod
|
|
292
292
|
|
|
293
|
-
def store(self,limit=10000000,batchSize=250,append=False,fixNone=True,sampleRecordCount=-1)->str:
|
|
293
|
+
def store(self,limit=10000000,batchSize=250,append=False,fixNone=True,sampleRecordCount=-1,replace:bool=False)->str:
|
|
294
294
|
'''
|
|
295
295
|
store my list of dicts
|
|
296
296
|
|
|
@@ -300,14 +300,15 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
|
|
|
300
300
|
append(bool): True if records should be appended
|
|
301
301
|
fixNone(bool): if True make sure the dicts are filled with None references for each record
|
|
302
302
|
sampleRecordCount(int): the number of records to analyze for type information
|
|
303
|
+
replace(bool): if True allow replace for insert
|
|
303
304
|
|
|
304
305
|
Return:
|
|
305
306
|
str: The cachefile being used
|
|
306
307
|
'''
|
|
307
308
|
lod=self.getLoD()
|
|
308
|
-
return self.storeLoD(lod,limit=limit,batchSize=batchSize,append=append,fixNone=fixNone,sampleRecordCount=sampleRecordCount)
|
|
309
|
+
return self.storeLoD(lod,limit=limit,batchSize=batchSize,append=append,fixNone=fixNone,sampleRecordCount=sampleRecordCount,replace=replace)
|
|
309
310
|
|
|
310
|
-
def storeLoD(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,append=False,fixNone=True,sampleRecordCount=1)->str:
|
|
311
|
+
def storeLoD(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,append=False,fixNone=True,sampleRecordCount=1,replace:bool=False)->str:
|
|
311
312
|
'''
|
|
312
313
|
store my entities
|
|
313
314
|
|
|
@@ -319,7 +320,7 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
|
|
|
319
320
|
append(bool): True if records should be appended
|
|
320
321
|
fixNone(bool): if True make sure the dicts are filled with None references for each record
|
|
321
322
|
sampleRecordCount(int): the number of records to analyze for type information
|
|
322
|
-
|
|
323
|
+
replace(bool): if True allow replace for insert
|
|
323
324
|
Return:
|
|
324
325
|
str: The cachefile being used
|
|
325
326
|
'''
|
|
@@ -358,8 +359,8 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
|
|
|
358
359
|
withDrop=True
|
|
359
360
|
withCreate=True
|
|
360
361
|
entityInfo=self.initSQLDB(sqldb,listOfDicts,withCreate=withCreate,withDrop=withDrop,sampleRecordCount=sampleRecordCount)
|
|
361
|
-
self.sqldb.store(listOfDicts, entityInfo,executeMany=self.executeMany,fixNone=fixNone)
|
|
362
|
+
self.sqldb.store(listOfDicts, entityInfo,executeMany=self.executeMany,fixNone=fixNone,replace=replace)
|
|
362
363
|
self.showProgress ("store for %s done after %5.1f secs" % (self.name,time.time()-startTime))
|
|
363
364
|
else:
|
|
364
|
-
raise Exception("unsupported store mode
|
|
365
|
+
raise Exception(f"unsupported store mode {self.mode}")
|
|
365
366
|
return cacheFile
|
|
@@ -124,7 +124,7 @@ class SQLDB(object):
|
|
|
124
124
|
debugInfo="\nrecord #%d" % index
|
|
125
125
|
return debugInfo
|
|
126
126
|
|
|
127
|
-
def store(self,listOfRecords,entityInfo,executeMany=False,fixNone=False):
|
|
127
|
+
def store(self,listOfRecords,entityInfo,executeMany=False,fixNone=False,replace=False):
|
|
128
128
|
'''
|
|
129
129
|
store the given list of records based on the given entityInfo
|
|
130
130
|
|
|
@@ -134,8 +134,9 @@ class SQLDB(object):
|
|
|
134
134
|
entityInfo(EntityInfo): the meta data to be used for storing
|
|
135
135
|
executeMany(bool): if True the insert command is done with many/all records at once
|
|
136
136
|
fixNone(bool): if True make sure empty columns in the listOfDict are filled with "None" values
|
|
137
|
+
replace(bool): if True allow replace for insert
|
|
137
138
|
'''
|
|
138
|
-
insertCmd=entityInfo.
|
|
139
|
+
insertCmd=entityInfo.getInsertCmd(replace=replace)
|
|
139
140
|
record=None
|
|
140
141
|
index=0
|
|
141
142
|
try:
|
|
@@ -507,12 +508,15 @@ class EntityInfo(object):
|
|
|
507
508
|
print (ddlCmd)
|
|
508
509
|
return ddlCmd
|
|
509
510
|
|
|
510
|
-
def getInsertCmd(self):
|
|
511
|
+
def getInsertCmd(self,replace:bool=False)->str:
|
|
511
512
|
'''
|
|
512
513
|
get the INSERT command for this entityInfo
|
|
513
514
|
|
|
515
|
+
Args:
|
|
516
|
+
replace(bool): if True allow replace for insert
|
|
517
|
+
|
|
514
518
|
Returns:
|
|
515
|
-
the INSERT INTO SQL command for his entityInfo e.g.
|
|
519
|
+
str: the INSERT INTO SQL command for his entityInfo e.g.
|
|
516
520
|
|
|
517
521
|
Example:
|
|
518
522
|
|
|
@@ -523,7 +527,8 @@ class EntityInfo(object):
|
|
|
523
527
|
'''
|
|
524
528
|
columns =','.join(self.typeMap.keys())
|
|
525
529
|
placeholders=':'+',:'.join(self.typeMap.keys())
|
|
526
|
-
|
|
530
|
+
replaceClause=" OR REPLACE" if replace else ""
|
|
531
|
+
insertCmd=f"INSERT{replaceClause} INTO {self.name} ({columns}) values ({placeholders})"
|
|
527
532
|
if self.debug:
|
|
528
533
|
print(insertCmd)
|
|
529
534
|
return insertCmd
|
|
@@ -9,7 +9,7 @@ class Version(object):
|
|
|
9
9
|
Version handling for pyLoDStorage
|
|
10
10
|
'''
|
|
11
11
|
name="pylodstorage"
|
|
12
|
-
version='0.4.
|
|
12
|
+
version='0.4.9'
|
|
13
13
|
date = '2020-09-10'
|
|
14
|
-
updated = '2022-
|
|
14
|
+
updated = '2022-12-18'
|
|
15
15
|
description='python List of Dict (Table) Storage library'
|
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
# Sample Queries for pyLodStorage library
|
|
3
3
|
#
|
|
4
4
|
# WF 2020-08-22
|
|
5
|
+
'classHistogramm':
|
|
6
|
+
sparql: |
|
|
7
|
+
SELECT ?c (COUNT(?c) AS ?count)
|
|
8
|
+
WHERE {
|
|
9
|
+
?subject a ?c
|
|
10
|
+
}
|
|
11
|
+
GROUP BY ?c
|
|
12
|
+
HAVING (?count >100)
|
|
13
|
+
ORDER BY DESC(?count)
|
|
14
|
+
'propertyHistogramm':
|
|
15
|
+
sparql: |
|
|
16
|
+
SELECT ?property (COUNT(?property) AS ?propTotal)
|
|
17
|
+
WHERE { ?s ?property ?o . }
|
|
18
|
+
GROUP BY ?property
|
|
19
|
+
HAVING (?propTotal >1000)
|
|
20
|
+
ORDER BY DESC(?propTotal)
|
|
5
21
|
'Predicate usage':
|
|
6
22
|
sparql: |
|
|
7
23
|
SELECT ?p (count(?p) as ?numberOfPredicates)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|