pyLodStorage 0.0.76__tar.gz → 0.0.77__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.
Files changed (27) hide show
  1. {pylodstorage-0.0.76/pylodstorage.egg-info → pylodstorage-0.0.77}/PKG-INFO +1 -1
  2. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/entity.py +26 -13
  3. {pylodstorage-0.0.76 → pylodstorage-0.0.77/pylodstorage.egg-info}/PKG-INFO +1 -1
  4. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/setup.py +1 -1
  5. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/LICENSE +0 -0
  6. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/README.md +0 -0
  7. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/__init__.py +0 -0
  8. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/csv.py +0 -0
  9. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/jsonable.py +0 -0
  10. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/jsonpicklemixin.py +0 -0
  11. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/lod.py +0 -0
  12. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/mwTable.py +0 -0
  13. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/plot.py +0 -0
  14. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/query.py +0 -0
  15. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/sample.py +0 -0
  16. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/schema.py +0 -0
  17. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/sparql.py +0 -0
  18. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/sql.py +0 -0
  19. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/storageconfig.py +0 -0
  20. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/tabulateCounter.py +0 -0
  21. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/uml.py +0 -0
  22. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/lodstorage/yamlablemixin.py +0 -0
  23. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/pylodstorage.egg-info/SOURCES.txt +0 -0
  24. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/pylodstorage.egg-info/dependency_links.txt +0 -0
  25. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/pylodstorage.egg-info/requires.txt +0 -0
  26. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/pylodstorage.egg-info/top_level.txt +0 -0
  27. {pylodstorage-0.0.76 → pylodstorage-0.0.77}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.76
3
+ Version: 0.0.77
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -10,6 +10,7 @@ from lodstorage.sparql import SPARQL
10
10
  from lodstorage.sql import SQLDB
11
11
  from lodstorage.lod import LOD
12
12
  from lodstorage.jsonable import JSONAbleList
13
+ import sys
13
14
  import os
14
15
  import time
15
16
 
@@ -148,26 +149,33 @@ GROUP by ?source
148
149
  elif mode is StoreMode.SQL:
149
150
  cacheFile=self.getCacheFile(config=self.config,mode=StoreMode.SQL)
150
151
  if os.path.isfile(cacheFile):
151
- sqlQuery="SELECT COUNT(*) AS count FROM %s" % self.tableName
152
+ sqlQuery=f"SELECT COUNT(*) AS count FROM {self.tableName}"
152
153
  try:
153
154
  sqlDB=self.getSQLDB(cacheFile)
154
- countResult=sqlDB.query(sqlQuery)
155
- count=countResult[0]['count']
156
- result=count>100
155
+ countResults=sqlDB.query(sqlQuery)
156
+ countResult=countResults[0]
157
+ count=countResult['count']
158
+ result=count>=0
157
159
  except Exception as ex:
160
+ msg=str(ex)
161
+ if self.debug:
162
+ print(msg,file=sys.stderr)
163
+ sys.stderr.flush()
158
164
  # e.g. sqlite3.OperationalError: no such table: Event_crossref
159
165
  pass
160
166
  else:
161
167
  raise Exception("unsupported mode %s" % self.mode)
162
168
  return result
163
169
 
164
- def fromCache(self,force:bool=False,getListOfDicts=None,sampleRecordCount=-1):
170
+ def fromCache(self,force:bool=False,getListOfDicts=None,withDrop=True,sampleRecordCount=-1):
165
171
  '''
166
- get my entries from the cache or from the callback provide
172
+ get my entries from the cache or from the callback provided
167
173
 
168
174
  Args:
169
175
  force(bool): force ignoring the cache
170
176
  getListOfDicts(callable): a function to call for getting the data
177
+ withDrop(bool): True if the table should be (re) created
178
+ sampleRecordCount(int): the number of records to analyze for type information
171
179
 
172
180
  Returns:
173
181
  the list of Dicts and as a side effect setting self.cacheFile
@@ -176,11 +184,14 @@ GROUP by ?source
176
184
  startTime=time.time()
177
185
  self.showProgress(f"getting {self.entityPluralName} for {self.name} ...")
178
186
  if getListOfDicts is None:
179
- getListOfDicts=self.getListOfDicts
187
+ if hasattr(self, "getListOfDicts"):
188
+ getListOfDicts=self.getListOfDicts
189
+ else:
190
+ raise Exception("from Cache failed and no secondary cache via getListOfDicts specified")
180
191
  listOfDicts=getListOfDicts()
181
192
  duration=time.time()-startTime
182
193
  self.showProgress(f"got {len(listOfDicts)} {self.entityPluralName} in {duration:5.1f} s")
183
- self.cacheFile=self.storeLoD(listOfDicts,sampleRecordCount=sampleRecordCount)
194
+ self.cacheFile=self.storeLoD(listOfDicts,withDrop=withDrop,sampleRecordCount=sampleRecordCount)
184
195
  self.setListFromLoD(listOfDicts)
185
196
  else:
186
197
  # fromStore also sets self.cacheFile
@@ -259,13 +270,14 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
259
270
  lod.append(entity.__dict__)
260
271
  return lod
261
272
 
262
- def store(self,limit=10000000,batchSize=250,fixNone=True,sampleRecordCount=-1)->str:
273
+ def store(self,limit=10000000,batchSize=250,withDrop=True,fixNone=True,sampleRecordCount=-1)->str:
263
274
  '''
264
275
  store my list of dicts
265
276
 
266
277
  Args:
267
- limit(int): maximum number of records to store
278
+ limit(int): maximum number of records to store per batch
268
279
  batchSize(int): size of batch for storing
280
+ withDrop(bool): True if the table should be (re) created
269
281
  fixNone(bool): if True make sure the dicts are filled with None references for each record
270
282
  sampleRecordCount(int): the number of records to analyze for type information
271
283
 
@@ -273,9 +285,9 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
273
285
  str: The cachefile being used
274
286
  '''
275
287
  lod=self.getLoD()
276
- return self.storeLoD(lod,limit=limit,batchSize=batchSize,fixNone=fixNone,sampleRecordCount=sampleRecordCount)
288
+ return self.storeLoD(lod,limit=limit,batchSize=batchSize,withDrop=withDrop,fixNone=fixNone,sampleRecordCount=sampleRecordCount)
277
289
 
278
- def storeLoD(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,fixNone=True,sampleRecordCount=1)->str:
290
+ def storeLoD(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,withDrop=True,fixNone=True,sampleRecordCount=1)->str:
279
291
  '''
280
292
  store my entities
281
293
 
@@ -284,6 +296,7 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
284
296
  limit(int): maximum number of records to store
285
297
  batchSize(int): size of batch for storing
286
298
  cacheFile(string): the name of the storage e.g path to JSON or sqlite3 file
299
+ withDrop(bool): True if the table should be (re) created
287
300
  fixNone(bool): if True make sure the dicts are filled with None references for each record
288
301
  sampleRecordCount(int): the number of records to analyze for type information
289
302
 
@@ -318,7 +331,7 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
318
331
  cacheFile=self.getCacheFile(config=self.config,mode=self.config.mode)
319
332
  sqldb=self.getSQLDB(cacheFile)
320
333
  self.showProgress ("storing %d %s for %s to %s:%s" % (len(listOfDicts),self.entityPluralName,self.name,config.mode,cacheFile))
321
- entityInfo=sqldb.createTable(listOfDicts, self.tableName, primaryKey=self.primaryKey,withDrop=True,sampleRecordCount=sampleRecordCount)
334
+ entityInfo=sqldb.createTable(listOfDicts, self.tableName, primaryKey=self.primaryKey,withDrop=withDrop,sampleRecordCount=sampleRecordCount)
322
335
  self.sqldb.store(listOfDicts, entityInfo,executeMany=self.executeMany,fixNone=fixNone)
323
336
  self.showProgress ("store for %s done after %5.1f secs" % (self.name,time.time()-startTime))
324
337
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.76
3
+ Version: 0.0.77
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -11,7 +11,7 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
11
11
 
12
12
  setup(
13
13
  name='pylodstorage',
14
- version='0.0.76',
14
+ version='0.0.77',
15
15
 
16
16
  packages=['lodstorage',],
17
17
  author='Wolfgang Fahl',
File without changes
File without changes
File without changes