Skip to content

Commit 44c8000

Browse files
authored
feat(python): Generate query code using ASTs instead of templates (#1338)
1 parent 2a65bfa commit 44c8000

File tree

15 files changed

+3153
-466
lines changed

15 files changed

+3153
-466
lines changed

examples/python/src/authors/query.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Code generated by sqlc. DO NOT EDIT.
32
from typing import AsyncIterator, Iterator, Optional
43

@@ -108,4 +107,3 @@ async def list_authors(self) -> AsyncIterator[models.Author]:
108107
name=row[1],
109108
bio=row[2],
110109
)
111-

examples/python/src/booktest/query.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
# Code generated by sqlc. DO NOT EDIT.
3-
from typing import AsyncIterator, List, Optional
42
import dataclasses
53
import datetime
4+
from typing import AsyncIterator, List, Optional
65

76
import sqlalchemy
87
import sqlalchemy.ext.asyncio
@@ -109,7 +108,6 @@ class CreateBookParams:
109108
"""
110109

111110

112-
113111
class AsyncQuerier:
114112
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
115113
self._conn = conn
@@ -208,4 +206,3 @@ async def update_book_isbn(self, *, title: str, tags: List[str], book_id: int, i
208206
"p3": book_id,
209207
"p4": isbn,
210208
})
211-

examples/python/src/jets/query-building.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Code generated by sqlc. DO NOT EDIT.
32
from typing import AsyncIterator, Optional
43

@@ -23,7 +22,6 @@
2322
"""
2423

2524

26-
2725
class AsyncQuerier:
2826
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
2927
self._conn = conn
@@ -44,4 +42,3 @@ async def list_pilots(self) -> AsyncIterator[models.Pilot]:
4442
id=row[0],
4543
name=row[1],
4644
)
47-

examples/python/src/ondeck/city.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Code generated by sqlc. DO NOT EDIT.
32
from typing import AsyncIterator, Optional
43

@@ -40,7 +39,6 @@
4039
"""
4140

4241

43-
4442
class AsyncQuerier:
4543
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
4644
self._conn = conn
@@ -73,4 +71,3 @@ async def list_cities(self) -> AsyncIterator[models.City]:
7371

7472
async def update_city_name(self, *, slug: str, name: str) -> None:
7573
await self._conn.execute(sqlalchemy.text(UPDATE_CITY_NAME), {"p1": slug, "p2": name})
76-

examples/python/src/ondeck/venue.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
# Code generated by sqlc. DO NOT EDIT.
3-
from typing import AsyncIterator, List, Optional
42
import dataclasses
3+
from typing import AsyncIterator, List, Optional
54

65
import sqlalchemy
76
import sqlalchemy.ext.asyncio
@@ -88,7 +87,6 @@ class VenueCountByCityRow:
8887
count: int
8988

9089

91-
9290
class AsyncQuerier:
9391
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
9492
self._conn = conn
@@ -156,4 +154,3 @@ async def venue_count_by_city(self) -> AsyncIterator[VenueCountByCityRow]:
156154
city=row[0],
157155
count=row[1],
158156
)
159-

0 commit comments

Comments
 (0)