Exemplo n.º 1
0
 def testSqllite3Speed(self):
     '''
     test sqlite3 speed with some 100000 artificial sample records
     consisting of two columns with a running index
     '''
     limit=100000
     listOfRecords=Sample.getSample(limit)
     self.checkListOfRecords(listOfRecords, 'Sample', 'pKey')  
Exemplo n.º 2
0
 def getSampleTableDB(withDrop=False,debug=False,failIfTooFew=False,sampleSize=1000):
     listOfRecords=Sample.getSample(sampleSize)
     sqlDB=SQLDB()
     entityName="sample"
     primaryKey='pKey'
     sampleRecordCount=sampleSize*10
     sqlDB.debug=debug
     entityInfo=sqlDB.createTable(listOfRecords, entityName, primaryKey=primaryKey, withDrop=withDrop, sampleRecordCount=sampleRecordCount,failIfTooFew=failIfTooFew)
     executeMany=True
     fixNone=True
     sqlDB.store(listOfRecords,entityInfo,executeMany=executeMany,fixNone=fixNone)
     return sqlDB
Exemplo n.º 3
0
 def testListOfDictSpeed(self):
     '''
     test the speed of adding data
     '''
     limit = 5000
     for batchSize in [None, 1000]:
         listOfDicts = Sample.getSample(limit)
         jena = self.getJena(mode='update', profile=self.profile)
         entityType = "ex:TestRecord"
         primaryKey = 'pkey'
         prefixes = 'PREFIX ex: <http://example.com/>'
         startTime = time.time()
         errors = jena.insertListOfDicts(listOfDicts,
                                         entityType,
                                         primaryKey,
                                         prefixes,
                                         batchSize=batchSize)
         self.checkErrors(errors)
         elapsed = time.time() - startTime
         if self.profile:
             print("adding %d records took %5.3f s => %5.f records/s" %
                   (limit, elapsed, limit / elapsed))
Exemplo n.º 4
0
 def testCopy(self):
     '''
     test copying databases into another database
     '''
     dbFile="/tmp/DAWT_Sample3x1000.db"
     copyDB=SQLDB(dbFile)
     for sampleNo in range(3):
         listOfRecords=Sample.getSample(1000)
         self.checkListOfRecords(listOfRecords, 'Sample_%d_1000' %sampleNo, 'pKey',doClose=False)  
         self.sqlDB.copyTo(copyDB)
     size=os.stat(dbFile).st_size
     if self.debug:
         print ("size of copy DB is %d" % size)
     self.assertTrue(size>70000)
     tableList=copyDB.getTableList()
     if self.debug:
         print(tableList)
     for sampleNo in range(3):
         self.assertEqual('Sample_%d_1000' %sampleNo,tableList[sampleNo]['name'])
     # check that database is writable
     # https://stackoverflow.com/a/44707371/1497139
     copyDB.execute("pragma user_version=0")