1
我正在閱讀文檔,看到你只需要在事務中提交一次?連接提交函數Python
以下計算爲一個事務還是每個函數都算作事務?
def main():
conn=pyodbc.connect(sqlconnectionstring) # Assume this connects to the database
cursor = conn.cursor()
function1()
function2()
conn.commit()
def function1():
# does inserting here
def function2():
# does inserting here and calls function 3
function3()
def function 3():
# does more inserting here
main()
那是conn.commit()足以提交所有插入的所有功能或我必須通過「conn將」變量作爲自變量,並承諾每個函數裏面?
謝謝!