Skip to content

Commit

Permalink
add "Transactions Support" section
Browse files Browse the repository at this point in the history
  • Loading branch information
imryche committed Jul 5, 2024
1 parent 36aceaf commit be5d9b5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,37 @@ async def main():
asyncio.run(main())
```

### Transaction Support

Litequery also supports transactions, allowing you to execute multiple queries
atomicaly.

```python
import litequery
import asyncio

async def main():
lq = litequery.setup("database.db", "queries.sql")
await lq.connect()

try:
async with lq.transaction():
await lq.insert_user(name="Charlie", email="[email protected]")
raise Exception("Force rollback")
await lq.insert_user(name="Eve", email="[email protected]")
except Exception:
print("Transaction failed")

users = await lq.get_all_users()
print(users)

await lq.disconnect()


asyncio.run(main())

```

## Wrapping Up

Litequery is all about simplicity and efficiency. Why wrestle with bloated ORMs
Expand Down

0 comments on commit be5d9b5

Please sign in to comment.