Changeset a3b83ea for asadb


Ignore:
Timestamp:
Jan 22, 2012, 11:03:38 PM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
8a8ba4c
Parents:
2ca295b
git-author:
Alex Dehnert <adehnert@…> (01/22/12 23:03:38)
git-committer:
Alex Dehnert <adehnert@…> (01/22/12 23:03:38)
Message:

Use transaction.commit_on_success for import_db.py

As usual, we get significant speed improvements (~4:45 -> 5 seconds,
so about a 60x improvement...).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/util/import_db.py

    r2ca295b ra3b83ea  
    1111    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    1212
     13from django.db import transaction
    1314import django.contrib.auth.models
    1415import reversion
     
    8485    g.save()
    8586
    86 if __name__ == '__main__':
    87     indb = sys.stdin
    88     reader = csv.DictReader(indb)
     87
     88@transaction.commit_on_success
     89def import_groups(reader):
    8990    with reversion.create_revision():
    9091        for line in reader:
     
    9495        reversion.set_user(importer)
    9596        reversion.set_comment("Groups importer")
     97
     98
     99if __name__ == '__main__':
     100    indb = sys.stdin
     101    reader = csv.DictReader(indb)
     102    import_groups(reader)
Note: See TracChangeset for help on using the changeset viewer.