Skip to content

Commit

Permalink
Added method execute_batch for Connection and Transaction
Browse files Browse the repository at this point in the history
Signed-off-by: chandr-andr (Kiselev Aleksandr) <[email protected]>
  • Loading branch information
chandr-andr committed Sep 19, 2024
1 parent db462de commit aa021ec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/components/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ async def main() -> None:
dict_results: list[dict[str, Any]] = results.result()
```

### Execute Batch

#### Parameters:

- `querystring`: querystrings separated by semicolons.

Executes a sequence of SQL statements using the simple query protocol.

Statements should be separated by semicolons.
If an error occurs, execution of the sequence will stop at that point.
This is intended for use when, for example,
initializing a database schema.

```python
async def main() -> None:
...
connection = await db_pool.connection()
await connection.execute_batch(
"CREATE TABLE psqlpy (name VARCHAR); CREATE TABLE psqlpy2 (name VARCHAR);",
)
```

### Fetch

#### Parameters:
Expand Down
23 changes: 23 additions & 0 deletions docs/components/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ async def main() -> None:
dict_results: list[dict[str, Any]] = results.result()
```

### Execute Batch

#### Parameters:

- `querystring`: querystrings separated by semicolons.

Executes a sequence of SQL statements using the simple query protocol.

Statements should be separated by semicolons.
If an error occurs, execution of the sequence will stop at that point.
This is intended for use when, for example,
initializing a database schema.

```python
async def main() -> None:
...
connection = await db_pool.connection()
async with connection.transaction() as transaction:
await transaction.execute_batch(
"CREATE TABLE psqlpy (name VARCHAR); CREATE TABLE psqlpy2 (name VARCHAR);",
)
```

### Fetch

#### Parameters:
Expand Down

0 comments on commit aa021ec

Please sign in to comment.