-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathquery.py
More file actions
43 lines (33 loc) · 1.04 KB
/
query.py
File metadata and controls
43 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Code generated by sqlc. DO NOT EDIT.
# versions:
# sqlc v1.27.0
# source: query.sql
from typing import AsyncIterator, Iterator
import sqlalchemy
import sqlalchemy.ext.asyncio
from db import models
LIST = """-- name: list \\:many
SELECT a, b, operation FROM operations
"""
class Querier:
def __init__(self, conn: sqlalchemy.engine.Connection):
self._conn = conn
def list(self) -> Iterator[models.Operation]:
result = self._conn.execute(sqlalchemy.text(LIST))
for row in result:
yield models.Operation(
a=row[0],
b=row[1],
operation=row[2],
)
class AsyncQuerier:
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
self._conn = conn
async def list(self) -> AsyncIterator[models.Operation]:
result = await self._conn.stream(sqlalchemy.text(LIST))
async for row in result:
yield models.Operation(
a=row[0],
b=row[1],
operation=row[2],
)