Skip to content

Commit

Permalink
feat(python): Generate query code using ASTs instead of templates (#1338
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kyleconroy committed Dec 15, 2021
1 parent 2a65bfa commit 44c8000
Show file tree
Hide file tree
Showing 15 changed files with 3,153 additions and 466 deletions.
2 changes: 0 additions & 2 deletions examples/python/src/authors/query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Code generated by sqlc. DO NOT EDIT.
from typing import AsyncIterator, Iterator, Optional

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

5 changes: 1 addition & 4 deletions examples/python/src/booktest/query.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# Code generated by sqlc. DO NOT EDIT.
from typing import AsyncIterator, List, Optional
import dataclasses
import datetime
from typing import AsyncIterator, List, Optional

import sqlalchemy
import sqlalchemy.ext.asyncio
Expand Down Expand Up @@ -109,7 +108,6 @@ class CreateBookParams:
"""



class AsyncQuerier:
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
self._conn = conn
Expand Down Expand Up @@ -208,4 +206,3 @@ async def update_book_isbn(self, *, title: str, tags: List[str], book_id: int, i
"p3": book_id,
"p4": isbn,
})

3 changes: 0 additions & 3 deletions examples/python/src/jets/query-building.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Code generated by sqlc. DO NOT EDIT.
from typing import AsyncIterator, Optional

Expand All @@ -23,7 +22,6 @@
"""



class AsyncQuerier:
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
self._conn = conn
Expand All @@ -44,4 +42,3 @@ async def list_pilots(self) -> AsyncIterator[models.Pilot]:
id=row[0],
name=row[1],
)

3 changes: 0 additions & 3 deletions examples/python/src/ondeck/city.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Code generated by sqlc. DO NOT EDIT.
from typing import AsyncIterator, Optional

Expand Down Expand Up @@ -40,7 +39,6 @@
"""



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

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

5 changes: 1 addition & 4 deletions examples/python/src/ondeck/venue.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# Code generated by sqlc. DO NOT EDIT.
from typing import AsyncIterator, List, Optional
import dataclasses
from typing import AsyncIterator, List, Optional

import sqlalchemy
import sqlalchemy.ext.asyncio
Expand Down Expand Up @@ -88,7 +87,6 @@ class VenueCountByCityRow:
count: int



class AsyncQuerier:
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
self._conn = conn
Expand Down Expand Up @@ -156,4 +154,3 @@ async def venue_count_by_city(self) -> AsyncIterator[VenueCountByCityRow]:
city=row[0],
count=row[1],
)

Loading

0 comments on commit 44c8000

Please sign in to comment.