【问题标题】:GAE, Cloud SQL and run_in_transactionGAE、Cloud SQL 和 run_in_transaction
【发布时间】:2012-11-13 20:13:45
【问题描述】:

我将 GAE 与 Cloud SQL 结合使用。

我似乎看不到文档中提到这一点,所以我想我只是想澄清一下我的理解。

是分组交易的标准方法,即:

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)

提前致谢, 马特

【问题讨论】:

    标签: google-app-engine transactions task-queue google-cloud-sql


    【解决方案1】:

    鉴于它是 db 组件的一部分,我认为 run_in_transaction 是特定于数据存储的。

    对于 CloudSQL,使用 SQL 事务命令 START TRANSACTION、COMMIT、ROLLBACK。

    【讨论】:

    • 是的。谢谢。希望我也能得到 GAE 团队的回复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 2013-09-13
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    • 2016-12-29
    相关资源
    最近更新 更多