Revision 146
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/lib/db_xml.py | ||
---|---|---|
33 | 33 |
elif child_name == name: return child |
34 | 34 |
return None |
35 | 35 |
|
36 |
def get(db, node, pkeys=None): |
|
36 |
def get(db, node, pkeys=None, limit=None):
|
|
37 | 37 |
if pkeys == None: pkeys = {} |
38 | 38 |
def pkey(table): return sql.pkey(db, pkeys, table) |
39 | 39 |
|
... | ... | |
52 | 52 |
if id_ != '': conds[pkey(table)] = id_ # replace any existing pkey value |
53 | 53 |
if fields == []: fields.append(pkey_) |
54 | 54 |
|
55 |
return sql.select(db, table, fields, conds) |
|
55 |
return sql.select(db, table, fields, conds, limit)
|
|
56 | 56 |
|
57 | 57 |
def put(db, node, store_ids=False, row_ct_ref=None, pkeys=None, parent_id=None): |
58 | 58 |
'''store_ids enables searching the tree for missing fields''' |
scripts/map | ||
---|---|---|
24 | 24 |
def usage_err(): |
25 | 25 |
raise SystemExit('Usage: '+opts.env_usage(env_names, True) |
26 | 26 |
+' [commit=1] '+sys.argv[0]+' [map_path] [<input] [>output]') |
27 |
limit = int(opts.get_env_var('n', sys.maxint, env_names)) |
|
27 |
limit = opts.get_env_var('n', None, env_names) |
|
28 |
if limit != None: limit = int(limit) |
|
28 | 29 |
commit = opts.env_flag('commit') |
29 | 30 |
|
30 | 31 |
# Get db config from env vars |
... | ... | |
92 | 93 |
in_db = sql.connect(in_db_config) |
93 | 94 |
in_pkeys = {} |
94 | 95 |
for row_idx, row in enumerate(sql.rows(db_xml.get(in_db, |
95 |
src_root_xml, in_pkeys))): |
|
96 |
if not row_idx < limit: break |
|
96 |
src_root_xml, in_pkeys, limit))): |
|
97 | 97 |
row_id, = row |
98 | 98 |
row_id = str(row_id) |
99 | 99 |
|
... | ... | |
112 | 112 |
reader = csv.reader(sys.stdin) |
113 | 113 |
cols = reader.next() |
114 | 114 |
for row_idx, row in enumerate(reader): |
115 |
if not row_idx < limit: break
|
|
115 |
if not (limit == None or row_idx < limit): break
|
|
116 | 116 |
row_id = str(row_idx) |
117 | 117 |
|
118 | 118 |
def put_col(path, value): |
Also available in: Unified diff
db_xml.get(): Pass limit through to SQL query