root/branch/ggpolo/umitDBUpdates/insert-changes-into-db.py @ 1431

Revision 1431, 0.8 kB (checked in by ggpolo, 6 years ago)

Huge speed gain on XML insertion into databaseng, including insertion on Inventory and calculating changes.

Line 
1#!/usr/bin/env python
2# Script for updating umitng database for new event storing schema.
3# Author: Guilherme Polo <ggpolo@gmail.com>
4
5"""
6Run this as: python insert-changes-into-db.py /path/to/my/umitng.db
7"""
8
9import sys
10from umitDB.InventoryChanges import ConnectToUpdate, UpdateChanges
11
12def perform_update(database):
13    """
14    Update changes for each inventory.
15    """
16    db_conn = ConnectToUpdate(database)
17
18    uc_instance = UpdateChanges(db_conn)
19    inv_ids = db_conn.get_inventories_ids()
20    inv_ids = [i_id[0] for i_id in inv_ids]
21   
22    for i_id in inv_ids:
23        uc_instance.do_update(i_id)
24
25    db_conn.conn.commit()
26
27if __name__ == "__main__":
28    if len(sys.argv) < 2:
29        print "You need to especify a database"
30        raise SystemExit
31
32    db = sys.argv[1]
33    perform_update(db)
Note: See TracBrowser for help on using the browser.