Skip to content

Commit

Permalink
fixes #39
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Jul 30, 2021
1 parent 5bd46b2 commit 3588d3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lodstorage/entity.py
Expand Up @@ -161,7 +161,7 @@ def isCached(self):
raise Exception("unsupported mode %s" % self.mode)
return result

def fromCache(self,force:bool=False,getListOfDicts=None):
def fromCache(self,force:bool=False,getListOfDicts=None,sampleRecordCount=-1):
'''
get my entries from the cache or from the callback provide
Expand All @@ -180,7 +180,7 @@ def fromCache(self,force:bool=False,getListOfDicts=None):
listOfDicts=getListOfDicts()
duration=time.time()-startTime
self.showProgress(f"got {len(listOfDicts)} {self.entityPluralName} in {duration:5.1f} s")
self.cacheFile=self.storeLoD(listOfDicts)
self.cacheFile=self.storeLoD(listOfDicts,sampleRecordCount=sampleRecordCount)
self.setListFromLoD(listOfDicts)
else:
# fromStore also sets self.cacheFile
Expand Down Expand Up @@ -275,7 +275,7 @@ def storeLoD(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,fixNon
Args:
listOfDicts(list): the list of dicts to store
limit(int): maximumn number of records to store
limit(int): maximum number of records to store
batchSize(int): size of batch for storing
cacheFile(string): the name of the storage e.g path to JSON or sqlite3 file
sampleRecordCount(int): the number of records to analyze for type information
Expand Down
2 changes: 2 additions & 0 deletions lodstorage/sql.py
Expand Up @@ -73,6 +73,8 @@ def createTable(self,listOfRecords,entityName,primaryKey=None,withDrop=False,sam
EntityInfo: meta data information for the created table
'''
l= len(listOfRecords)
if sampleRecordCount<0:
sampleRecordCount=l
if l<sampleRecordCount:
msg="only %d/%d of needed sample records to createTable available" % (l,sampleRecordCount)
if failIfTooFew:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -11,7 +11,7 @@

setup(
name='pylodstorage',
version='0.0.59',
version='0.0.60',

packages=['lodstorage',],
author='Wolfgang Fahl',
Expand Down

0 comments on commit 3588d3f

Please sign in to comment.