Skip to content

Commit

Permalink
psycopg2: Accept Composable in place of query string (#7494)
Browse files Browse the repository at this point in the history
https://www.psycopg.org/docs/sql.html#psycopg2.sql.Composable
“Composable objects can be passed directly to execute(),
executemany(), copy_expert() in place of the query string.”

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Mar 16, 2022
1 parent fdc5863 commit b78f0c2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions stubs/psycopg2/psycopg2/_psycopg.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from typing import Any, TypeVar, overload

import psycopg2
import psycopg2.extensions
from psycopg2.sql import Composable

_Vars = Sequence[Any] | Mapping[str, Any] | None

Expand Down Expand Up @@ -360,11 +361,11 @@ class cursor:
def callproc(self, procname, parameters=...): ...
def cast(self, oid, s): ...
def close(self): ...
def copy_expert(self, sql, file, size=...): ...
def copy_expert(self, sql: str | bytes | Composable, file, size=...): ...
def copy_from(self, file, table, sep=..., null=..., size=..., columns=...): ...
def copy_to(self, file, table, sep=..., null=..., columns=...): ...
def execute(self, query: str | bytes, vars: _Vars = ...) -> None: ...
def executemany(self, query: str | bytes, vars_list: Iterable[_Vars]) -> None: ...
def execute(self, query: str | bytes | Composable, vars: _Vars = ...) -> None: ...
def executemany(self, query: str | bytes | Composable, vars_list: Iterable[_Vars]) -> None: ...
def fetchall(self) -> list[tuple[Any, ...]]: ...
def fetchmany(self, size=...) -> list[tuple[Any, ...]]: ...
def fetchone(self) -> tuple[Any, ...] | Any: ...
Expand Down

0 comments on commit b78f0c2

Please sign in to comment.