【发布时间】:2023-01-27 22:50:55
【问题描述】:
我创建了一个 python 脚本,它打开一个大型 SQL 文件(+50k 行),其中插入到表中。
代码运行良好,但需要几个小时,我想知道我是否可以显示进度条(tqdm 似乎不适用于这种情况)或只显示“通过时间”
代码:
def runScript(file):
with open(file,'r') as f:
sql = f.read()
...
with conn.cursor() as cursor:
c.execute(sql) # --> this takes a lot of time
tqdm 不起作用(或至少不显示任何内容)。
我可以逐行阅读并使用 tqdm,但它需要更多时间。
任何想法表示赞赏。
【问题讨论】: