更高效的sql炼金术函数?

68bkxrlz  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(199)

我终于可以运行insert代码并将行插入到mysql/mariadb数据库中,但是当我循环下面的函数时,即使只有很少的行(比如4行),运行也需要2分钟。有人能告诉我在insert函数中我做错了什么吗? def ProcessMsg(msg_id, reg_num, sent_date, subject): # Insert into Database row_data = {} row_data['msg_id'] = msg_id row_data['reg_num'] = reg_num row_data['sent_date'] = sent_date row_data['subject'] = subject metadata = MetaData(bind=engine) msg_in = Table('msg_inbound', metadata, autoload=True) conn = engine.connect() Session = sessionmaker(bind=conn) session = Session() i = insert(msg_in) i = i.values({"msg_id": row_data['msg_id'], "reg_num": row_data['reg_num'], "sent_date": row_data['sent_date'], "subject": row_data['subject'] }) session.execute(i) session.commit() session.close()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题