Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MysqlIdGenerator:
- def __init__(self, engine):
- self.engine = engine
- async def next(self, table):
- tpl = "REPLACE INTO {} (stub) VALUES ('a');"
- sql = tpl.format(table.name)
- sel = "SELECT LAST_INSERT_ID();"
- async with self.engine.acquire() as conn:
- await conn.execute(sql)
- return await (await conn.execute(sel)).scalar()
Add Comment
Please, Sign In to add comment