Revision 310
Added by Aaron Marcuse-Kubitza about 13 years ago
bin/map | ||
---|---|---|
13 | 13 |
import opts |
14 | 14 |
import Parser |
15 | 15 |
import sql |
16 |
import util |
|
16 | 17 |
import xml_dom |
17 | 18 |
import xml_func |
18 | 19 |
|
... | ... | |
93 | 94 |
try: xpath.put_obj(root, out, row_id, has_types, value) |
94 | 95 |
except Exception: traceback.print_exc() |
95 | 96 |
|
96 |
if map_path == None: return doc0 |
|
97 |
if map_path == None: |
|
98 |
iter_ = xml_dom.NodeElemIter(doc0.documentElement) |
|
99 |
util.skip(iter_, xml_dom.is_text) # skip metadata |
|
100 |
#map(use_row, iter_) |
|
101 |
return doc0 |
|
97 | 102 |
elif in_is_db: |
98 | 103 |
assert in_is_xpaths |
99 | 104 |
|
... | ... | |
150 | 155 |
|
151 | 156 |
out_db = sql.connect(out_db_config) |
152 | 157 |
out_db.set_isolation_level(ISOLATION_LEVEL_SERIALIZABLE) |
158 |
out_pkeys = {} |
|
153 | 159 |
try: |
154 | 160 |
row_ct_ref = [0] |
155 |
def use_row(root): db_xml.xml2db(out_db, root, commit, row_ct_ref) |
|
161 |
def use_row(root): |
|
162 |
try: |
|
163 |
put(out_db, root, False, row_ct_ref, out_pkeys) |
|
164 |
if commit: db.commit() |
|
165 |
except Exception: |
|
166 |
out_db.rollback() |
|
167 |
traceback.print_exc() |
|
156 | 168 |
db_xml.xml2db(out_db, process_input(use_row).documentElement, |
157 | 169 |
commit, row_ct_ref) |
158 | 170 |
print 'Inserted '+str(row_ct_ref[0])+' rows' |
Also available in: Unified diff
bin/map: Added commit and exception-handling code to out_is_db use_row()