Skip to content

Commit

Permalink
Better feedback when processImportFile fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Smith committed Nov 4, 2014
1 parent 8f1e7a7 commit 8d2aa0c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion buildcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,29 @@ def processImportFile(db, importPath, tableName, debug=0):

# import the data
importCount = 0
lineNo = 0
for linein in csvin:
if len(linein) == columnCount:
if debug > 1:
print("- Values: {}".format(', '.join(linein)))
db.execute(sql_stmt, linein)
try:
db.execute(sql_stmt, linein)
except Exception as e:
raise SystemExit(
"*** INTERNAL ERROR: {err}\n"
"CSV File: {file}:{line}\n"
"SQL Query: {query}\n"
"Params: {params}\n"
.format(
err=str(e),
file=str(importPath),
line=lineNo,
query=sql_stmt.strip(),
params=linein
)
) from None
importCount += 1
++lineNo
db.commit()
if debug:
print("* {count} {table}s imported". \
Expand Down

0 comments on commit 8d2aa0c

Please sign in to comment.