psycopg2: Accept Composable in place of query string (#7494)

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 <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2022-03-15 20:47:30 -07:00
committed by GitHub
parent fdc5863337
commit b78f0c21ba

View File

@@ -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
@@ -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: ...