Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ff13ad

Browse files
committed
Add support for:copyfrom via executemany()
1 parent53fa0b2 commit2ff13ad

File tree

44 files changed

+435
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+435
-45
lines changed

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ bin
55
.direnv
66
.devenv*
77
devenv.local.nix
8+
9+
.idea/

‎examples/src/authors/models.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
importdataclasses
55
fromtypingimportOptional
66

‎examples/src/authors/query.py‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
# source: query.sql
5-
fromtypingimportAsyncIterator,Iterator,Optional
5+
fromtypingimportAny,AsyncIterator,Iterator,List,Optional
66

77
importsqlalchemy
88
importsqlalchemy.ext.asyncio
@@ -20,6 +20,11 @@
2020
"""
2121

2222

23+
CREATE_AUTHORS_BATCH="""-- name: create_authors_batch\\:copyfrom
24+
INSERT INTO authors (name, bio) VALUES (:p1, :p2)
25+
"""
26+
27+
2328
DELETE_AUTHOR="""-- name: delete_author\\:exec
2429
DELETE FROM authors
2530
WHERE id = :p1
@@ -52,6 +57,10 @@ def create_author(self, *, name: str, bio: Optional[str]) -> Optional[models.Aut
5257
bio=row[2],
5358
)
5459

60+
defcreate_authors_batch(self,arg_list:List[Any])->int:
61+
result=self._conn.executemany(sqlalchemy.text(CREATE_AUTHORS_BATCH),arg_list)
62+
returnresult.rowcount
63+
5564
defdelete_author(self,*,id:int)->None:
5665
self._conn.execute(sqlalchemy.text(DELETE_AUTHOR), {"p1":id})
5766

@@ -89,6 +98,10 @@ async def create_author(self, *, name: str, bio: Optional[str]) -> Optional[mode
8998
bio=row[2],
9099
)
91100

101+
asyncdefcreate_authors_batch(self,arg_list:List[Any])->int:
102+
result=awaitself._conn.executemany(sqlalchemy.text(CREATE_AUTHORS_BATCH),arg_list)
103+
returnresult.rowcount
104+
92105
asyncdefdelete_author(self,*,id:int)->None:
93106
awaitself._conn.execute(sqlalchemy.text(DELETE_AUTHOR), {"p1":id})
94107

‎examples/src/authors/query.sql‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ RETURNING *;
1717
-- name: DeleteAuthor :exec
1818
DELETEFROM authors
1919
WHERE id= $1;
20+
21+
-- name: CreateAuthorsBatch :copyfrom
22+
INSERT INTO authors (name, bio)VALUES ($1, $2);

‎examples/src/booktest/models.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
importdataclasses
55
importdatetime
66
importenum

‎examples/src/booktest/query.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
# source: query.sql
55
importdataclasses
66
importdatetime

‎examples/src/jets/models.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
importdataclasses
55

66

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
# source: query-building.sql
55
fromtypingimportAsyncIterator,Optional
66

‎examples/src/ondeck/city.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
# source: city.sql
55
fromtypingimportAsyncIterator,Optional
66

‎examples/src/ondeck/models.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code generated by sqlc. DO NOT EDIT.
22
# versions:
3-
# sqlc v1.28.0
3+
# sqlc v1.29.0
44
importdataclasses
55
importdatetime
66
importenum

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp