python-gino / gino

GINO Is Not ORM - a Python asyncio ORM on SQLAlchemy core.
https://python-gino.org/
Other
2.67k stars 150 forks source link

Flushing inside transaction #732

Closed MaximAdler closed 3 years ago

MaximAdler commented 3 years ago

Description

I haven't found functionality to flush changes inside transactions. ( Like in SQLAlchemy ). Is it implemented?

What I Want

from sqlalchemy.schema import CreateSchema

async with db.transaction() as tx:
    name = 'test'
    db.status(CreateSchema(f'{name}_schema'))

    # Here I want something like tx.flush() to apply changes to the DB but not commit

    await db.status(f"CREATE ROLE {name} WITH LOGIN")
    await db.status(f'GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA {name}_schema TO {name}')

At the moment of granting privileges, there is no schema with the name 'test_schema' in DB. And I need to do it inside the transaction and commit after creating the role with permissions for the schema.

mooksel commented 3 years ago

@MaximAdler, why did You close this issue? Have You found needed API method or a workaround?

MaximAdler commented 3 years ago

Have You found needed API method or a workaround?

Yeah, actually I don't need to do that manually, and if I understood right, flushing makes automatically.