def check_dataset(self):
'''
check if dataset is already in database
if found set self.dataset_id to the entry in the database
return boolean
'''
self.cursor.execute('select id as rowid, name from dataset')
citems = self.cursor.fetchall()
names = [citem['name'] for citem in citems] # get all names
if names:
try:
idx = numpy.where(numpy.array(names)==self.datasetname)[0][0]
self.dataset_id = citems[idx]['rowid']
return True
except IndexError:
return False
else:
return False
评论列表
文章目录