There was an error while loading. Please reload this page.
1 parent 169805e commit 414cbafCopy full SHA for 414cbaf
1 file changed
labs/travelapp/run_sql_file.py
@@ -71,9 +71,19 @@ def resolve_region():
71
batch_num += 1
72
try:
73
cursor.execute(batch)
74
- # Fetch and print messages
75
- while cursor.nextset():
76
- pass
+ # Print any result sets
+ while True:
+ if cursor.description:
77
+ cols = [d[0] for d in cursor.description]
78
+ rows = cursor.fetchall()
79
+ if rows:
80
+ print(' '.join(cols))
81
+ print(' '.join(['-' * len(c) for c in cols]))
82
+ for row in rows:
83
+ print(' '.join([str(v) if v is not None else 'NULL' for v in row]))
84
+ print()
85
+ if not cursor.nextset():
86
+ break
87
except Exception as e:
88
print(f"Error in batch {batch_num}: {e}")
89
0 commit comments