__init__.pyi 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from collections import deque
  10. from collections.abc import Sequence
  11. from contextlib import AbstractContextManager
  12. from ssl import SSLContext
  13. from types import TracebackType
  14. from typing import IO, Any, AnyStr
  15. class Connection:
  16. autocommit: bool
  17. notices: deque
  18. def cursor(self) -> Cursor: ...
  19. def close(self) -> None: ...
  20. def run(self, sql: str, stream: IO[AnyStr] | None = None) -> list[list[Any]]: ...
  21. def commit(self) -> None: ...
  22. def rollback(self) -> None: ...
  23. class Cursor(AbstractContextManager):
  24. rowcount: int
  25. connection: Connection
  26. _c: Connection
  27. def close(self) -> None: ...
  28. def execute(self, sql: str) -> None: ...
  29. def fetchall(self) -> Sequence[Sequence[Any]]: ...
  30. def fetchone(self) -> Sequence[Any]: ...
  31. def __exit__(
  32. self,
  33. typ: type[BaseException] | None,
  34. value: BaseException | None,
  35. traceback: TracebackType | None,
  36. ) -> None: ...
  37. def connect(
  38. host: str = ...,
  39. port: int = ...,
  40. user: str = ...,
  41. database: str | None = ...,
  42. password: str | None = ...,
  43. timeout: int | None = ...,
  44. ssl_context: SSLContext | None = ...,
  45. application_name: str | None = ...,
  46. startup_params: dict[str, str] | None = ...,
  47. ) -> Connection: ...