Revision 5164
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_io.py | ||
---|---|---|
247 | 247 |
else: |
248 | 248 |
log('Using INSERT') |
249 | 249 |
cols_ct = len(stream_info.header) |
250 |
row_ct = 0 |
|
251 |
inserted_row_ct = 0 |
|
250 | 252 |
for row in csvs.make_reader(stream, dialect): |
253 |
row_ct += 1 |
|
251 | 254 |
row = map(strings.to_unicode, row) |
252 | 255 |
util.list_set_length(row, cols_ct) # truncate extra cols |
253 |
sql.insert(db, table, row, ignore=True, cacheable=False, |
|
254 |
log_level=5) |
|
256 |
if sql.insert(db, table, row, ignore=True, cacheable=False, |
|
257 |
log_level=5) != None: |
|
258 |
inserted_row_ct += 1 |
|
259 |
log('Inserted '+str(inserted_row_ct)+' of '+str(row_ct)+' rows') |
|
255 | 260 |
|
256 | 261 |
def import_csv(db, table, stream, use_copy_from=True): |
257 | 262 |
def log(msg, level=1): db.log_debug(msg, level) |
Also available in: Unified diff
sql_io.py: append_csv(): In INSERT mode, print # rows read (different from # lines read if some fields contained embedded newlines) and # rows inserted (different from # rows read if some violated a constraint)