Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion taxadb/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def create_db(args):
if div in ['full', 'prot']:
acc_dl_list.append(prot)
parser = Accession2TaxidParser(verbose=args.verbose, fast=args.fast)
with db.atomic():
with db.atomic() as txn:
for acc_file in acc_dl_list:
inserted_rows = 0
logger.info("Parsing %s" % str(acc_file))
Expand All @@ -149,13 +149,15 @@ def create_db(args):
logger.info('%s: %s added to database (%d rows inserted)'
% (Accession.get_table_name(),
acc_file, inserted_rows))
txn.commit()
if not Accession.has_index(name='accession_accession'):
logger.info('Creating index for %s'
% Accession.get_table_name())
try:
# db.add_index(Accession, ['accession'], unique=True)
idx = db.index(db.Accession, name='accession', unique=True)
db.add_index(idx)
txn.commit()
except PeeweeException as err:
raise Exception("Could not create Accession index: %s"
% str(err))
Expand Down