Snowflake Connector for Python中的事务和回滚

Snowflake Connector for Python中的事务和回滚,python,python-3.x,transactions,rollback,snowflake-cloud-data-platform,Python,Python 3.x,Transactions,Rollback,Snowflake Cloud Data Platform,我正在使用Python的雪花连接器,如下所示: ctx = snowflake.connector.connect(user=username, password=password, account=account, warehouse=warehouse) cs = ctx.cursor() try: cs.execute(u"begin") cs.execute("TRUNCATE table1") cs.execute("TRUNCATE table2") cs.execute("

我正在使用Python的雪花连接器,如下所示:

ctx = snowflake.connector.connect(user=username, password=password, account=account, warehouse=warehouse)
cs = ctx.cursor()
try:
 cs.execute(u"begin")
 cs.execute("TRUNCATE table1")
 cs.execute("TRUNCATE table2")
 cs.execute("TRUNCATE table3")
 ctx.commit()
except snowflake.connector.errors.ProgrammingError as e:
  ctx.rollback()
  print("ERROR" + e.msg)
finally:
  cs.close()
  ctx.close()
本质上,我希望在任何SQLs(截断)出现任何问题时回滚。但这段代码似乎没有回滚

您知道是什么原因导致了这种情况吗?

从中,您必须将“自动提交”设置为False才能使回滚正常工作,但是,即使设置了自动提交,也无法使其正常工作。请发布您的调查结果

ctx = snowflake.connector.connect(autocommit=False,user=username, password=password, account=account, warehouse=warehouse)

你一定对雪花的交易部分感兴趣。但我认为您必须使用DML语句作为truncate作为DDL,并具有自己的autocommit事务,相反,您可以使用简单的delete@根据Snowflake文档,TRUNCATE是一个DML命令:delete没有解决问题吗<代码>事务\u中止\u ON \u错误您是否将其设置为真?如何使用Python连接器设置事务\u中止\u ON \u错误?