Revision 295
Added by Aaron Marcuse-Kubitza about 13 years ago
lib/db_xml.py | ||
---|---|---|
103 | 103 |
|
104 | 104 |
return id_ |
105 | 105 |
|
106 |
def xml2db(db, node, row_ct_ref=None): |
|
106 |
def xml2db(db, node, commit=False, row_ct_ref=None):
|
|
107 | 107 |
iter_ = xml_dom.NodeElemIter(node) |
108 | 108 |
util.skip(iter_, xml_dom.is_text) # skip metadata |
109 | 109 |
for child in iter_: |
110 |
try: put(db, child, False, row_ct_ref) |
|
111 |
except Exception: traceback.print_exc() |
|
110 |
try: |
|
111 |
put(db, child, False, row_ct_ref) |
|
112 |
if commit: db.commit() |
|
113 |
except Exception: |
|
114 |
db.rollback() |
|
115 |
traceback.print_exc() |
bin/map | ||
---|---|---|
159 | 159 |
out_db.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE) |
160 | 160 |
try: |
161 | 161 |
row_ct_ref = [0] |
162 |
def use_row(root): db_xml.xml2db(out_db, root, row_ct_ref) |
|
162 |
def use_row(root): db_xml.xml2db(out_db, root, commit, row_ct_ref)
|
|
163 | 163 |
db_xml.xml2db(out_db, get_xml(use_row).documentElement, row_ct_ref) |
164 | 164 |
print 'Inserted '+str(row_ct_ref[0])+' rows' |
165 |
if commit: out_db.commit() |
|
166 | 165 |
finally: |
167 | 166 |
out_db.rollback() |
168 | 167 |
out_db.close() |
Also available in: Unified diff
Commit after inserting each row