Last active
January 18, 2021 22:39
-
-
Save evgenii-malov/96d1b7873aaba0cf6ff2d45ca46f7dee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def insert_one(pool, sql, params): | |
async with pool.acquire() as conn: | |
async with conn.cursor() as cur: | |
try: | |
await cur.execute(sql, params) | |
value = await cur.fetchone() | |
except Exception as e: | |
await conn.rollback() | |
raise e | |
else: | |
await conn.commit() | |
return cur.lastrowid | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment