Revision 40
Added by Aaron Marcuse-Kubitza about 13 years ago
db_util.py | ||
---|---|---|
92 | 92 |
check_name(table) |
93 | 93 |
return col(run_query(db, 'SELECT * FROM '+table+' LIMIT 0'), 0) |
94 | 94 |
|
95 |
def insert_or_get(db, table, row, pkey, row_ct_ref=None):
|
|
95 |
def get(db, table, row, pkey, create=False, row_ct_ref=None):
|
|
96 | 96 |
try: return value(select(db, table, [pkey], row)) |
97 | 97 |
except StopIteration: |
98 |
if not create: raise |
|
99 |
# Insert new row |
|
98 | 100 |
try: |
99 | 101 |
row_ct = try_insert(db, table, row).rowcount |
100 | 102 |
if row_ct_ref != None and row_ct >= 0: row_ct_ref[0] += row_ct |
Also available in: Unified diff
xml2db: Started refactoring xml2db() to support getting as well as inserting data