ahopkins/mayim

Is mysql.interface line 70 supposed to be not transaction?

Closed this issue · 4 comments

xxxzc commented

Mysql executor does not commit after executing update sql, is mysql.interface line 70 supposed to be not transaction?

else:
transaction = self.in_transaction()
async with self._pool.acquire() as conn:
if transaction:
await conn.begin()
yield conn
if transaction:
if self.do_commit():
await conn.commit()

After changing to not transaction, the update was committed normally

Are you trying to use it in a transaction or not?

xxxzc commented

My code looks like this:

class ConfigExecutor(MysqlExecutor):
    @query("""
        update t_config set config=$config where source=$source
    """)
    async def update_config(self, source: str, config: str):
        ...

How do I commit this update with or without a transaction?

Having similar issue. SELECT statements work fine, but an UPDATE statement will not commit unless writing the SQL file as a transaction. Do you have any UPDATE examples showing this and how to handle a transaction that did not complete successfully?

#53 (comment)

@slipstream77

This should be done

Are you trying to use it in a transaction or not?