forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.py
More file actions
92 lines (56 loc) · 2.04 KB
/
query.py
File metadata and controls
92 lines (56 loc) · 2.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Code generated by sqlc. DO NOT EDIT.
from typing import AsyncIterator, Awaitable, Iterator, Optional, overload
import sqlc_runtime as sqlc
from authors import models
CREATE_AUTHOR = """-- name: create_author :one
INSERT INTO authors (
name, bio
) VALUES (
$1, $2
)
RETURNING id, name, bio
"""
DELETE_AUTHOR = """-- name: delete_author :exec
DELETE FROM authors
WHERE id = $1
"""
GET_AUTHOR = """-- name: get_author :one
SELECT id, name, bio FROM authors
WHERE id = $1 LIMIT 1
"""
LIST_AUTHORS = """-- name: list_authors :many
SELECT id, name, bio FROM authors
ORDER BY name
"""
@overload
def create_author(conn: sqlc.Connection, name: str, bio: Optional[str]) -> Optional[models.Author]:
pass
@overload
def create_author(conn: sqlc.AsyncConnection, name: str, bio: Optional[str]) -> Awaitable[Optional[models.Author]]:
pass
def create_author(conn: sqlc.GenericConnection, name: str, bio: Optional[str]) -> sqlc.ReturnType[Optional[models.Author]]:
return conn.execute_one_model(models.Author, CREATE_AUTHOR, name, bio)
@overload
def delete_author(conn: sqlc.Connection, id: int) -> None:
pass
@overload
def delete_author(conn: sqlc.AsyncConnection, id: int) -> Awaitable[None]:
pass
def delete_author(conn: sqlc.GenericConnection, id: int) -> sqlc.ReturnType[None]:
return conn.execute_none(DELETE_AUTHOR, id)
@overload
def get_author(conn: sqlc.Connection, id: int) -> Optional[models.Author]:
pass
@overload
def get_author(conn: sqlc.AsyncConnection, id: int) -> Awaitable[Optional[models.Author]]:
pass
def get_author(conn: sqlc.GenericConnection, id: int) -> sqlc.ReturnType[Optional[models.Author]]:
return conn.execute_one_model(models.Author, GET_AUTHOR, id)
@overload
def list_authors(conn: sqlc.Connection) -> Iterator[models.Author]:
pass
@overload
def list_authors(conn: sqlc.AsyncConnection) -> AsyncIterator[models.Author]:
pass
def list_authors(conn: sqlc.GenericConnection) -> sqlc.IteratorReturn[models.Author]:
return conn.execute_many_model(models.Author, LIST_AUTHORS)