2

我正在使用GAE和Cloud SQL。GAE,Cloud SQL和run_in_transaction

我似乎無法看到在文檔中提到的這一點,所以我想我會問,只是爲了澄清我的理解。

是分組數據的標準方法,即:

def do_something_in_transaction(...) 
    update my CloudSQL database record 
    taskqueue.add(url='/path/to/my/worker', transactional=True) 
    ... 

db.run_in_transaction(do_something_in_transaction, ....) 

假定爲雲SQL工作?

也可以在run_in_transaction調用期間更新/插入/刪除多個記錄(即儘可能多的記錄)?

即:

def do_something_in_transaction(...) 
    x_id = insert record into table x 
    update table y record with x_id 
    insert record into table a 
    insert record into table b 
    … etc 
    taskqueue.add(url='/path/to/my/worker', transactional=True) 

由於提前, 馬特

回答

2

考慮到它的數據庫組件的一部分,我認爲run_in_transaction是特定於數據存儲。

對於CloudSQL,使用SQL事務命令START TRANSACTION,COMMIT,ROLLBACK。

+0

是的。謝謝。希望我也會收到GAE團隊的回覆。 – Sway