diff --git a/stubs/hdbcli/@tests/stubtest_allowlist.txt b/stubs/hdbcli/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..d73612be9 --- /dev/null +++ b/stubs/hdbcli/@tests/stubtest_allowlist.txt @@ -0,0 +1,4 @@ +hdbcli.dbapi.Error.errorcode +hdbcli.dbapi.Error.errortext +hdbcli.dbapi.Warning.errorcode +hdbcli.dbapi.Warning.errortext diff --git a/stubs/hdbcli/METADATA.toml b/stubs/hdbcli/METADATA.toml new file mode 100644 index 000000000..4e51482b6 --- /dev/null +++ b/stubs/hdbcli/METADATA.toml @@ -0,0 +1 @@ +version = "2.10.*" diff --git a/stubs/hdbcli/hdbcli/__init__.pyi b/stubs/hdbcli/hdbcli/__init__.pyi new file mode 100644 index 000000000..bda5b5a7f --- /dev/null +++ b/stubs/hdbcli/hdbcli/__init__.pyi @@ -0,0 +1 @@ +__version__: str diff --git a/stubs/hdbcli/hdbcli/dbapi.pyi b/stubs/hdbcli/hdbcli/dbapi.pyi new file mode 100644 index 000000000..7ab8c8be9 --- /dev/null +++ b/stubs/hdbcli/hdbcli/dbapi.pyi @@ -0,0 +1,115 @@ +import decimal +from _typeshed import ReadableBuffer +from datetime import date, datetime, time +from typing import Any, Sequence, Tuple, Type, overload +from typing_extensions import Literal + +from .resultrow import ResultRow + +apilevel: str +threadsafety: int +paramstyle: Tuple[str, ...] +connect = Connection + +class Connection: + def __init__( + self, + address: str, + port: int, + username: str, + password: str, + autocommit: bool = ..., + packetsize: int | None = ..., + userkey: str | None = ..., + *, + sessionvariables: dict[str, str] | None = ..., + forcebulkfetch: bool | None = ..., + ) -> None: ... + def cancel(self) -> bool: ... + def close(self) -> None: ... + def commit(self) -> None: ... + def cursor(self) -> Cursor: ... + def getaddress(self) -> str: ... + def getautocommit(self) -> bool: ... + def getclientinfo(self, key: str = ...) -> str | dict[str, str]: ... + def isconnected(self) -> bool: ... + def rollback(self) -> None: ... + def setautocommit(self, auto: bool = ...) -> None: ... + def setclientinfo(self, key: str, value: str | None = ...) -> None: ... + +class LOB: + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def close(self) -> bool: ... + def find(self, object: str, length: int, position: int = ...) -> int: ... + def read(self, size: int = ..., position: int = ...) -> str | bytes: ... + def write(self, object: str | bytes) -> int: ... + +_Parameters = Sequence[Tuple[Any, ...]] + +class Cursor: + description: Tuple[Tuple[Any, ...], ...] + rowcount: int + statementhash: str | None + connection: Connection + arraysize: int + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def callproc(self, procname: str, parameters: Tuple[Any, ...] = ..., overview: bool = ...) -> Tuple[Any, ...]: ... + def close(self) -> None: ... + def description_ext(self) -> Sequence[Tuple[Any, ...]]: ... + def execute(self, operation: str, parameters: Tuple[Any, ...]) -> bool: ... + def executemany(self, operation: str, parameters: _Parameters) -> Any: ... + def executemanyprepared(self, parameters: _Parameters) -> Any: ... + def executeprepared(self, parameters: _Parameters = ...) -> Any: ... + def fetchone(self, uselob: bool = ...) -> ResultRow | None: ... + def fetchall(self) -> list[ResultRow]: ... + def fetchmany(self, size: int | None = ...) -> list[ResultRow]: ... + def get_resultset_holdability(self) -> int: ... + def getwarning(self) -> Warning | None: ... + def haswarning(self) -> bool: ... + def nextset(self) -> None: ... + def parameter_description(self) -> Tuple[str, ...]: ... + @overload + def prepare(self, operation: str, newcursor: Literal[True]) -> Cursor: ... + @overload + def prepare(self, operation: str, newcursor: Literal[False]) -> Any: ... + def scroll(self, value: int, mode: Literal["absolute"] | Literal["relative"] = ...) -> None: ... + def server_cpu_time(self) -> int: ... + def server_memory_usage(self) -> int: ... + def server_processing_time(self) -> int: ... + def setinputsizes(self, *args: Any, **kwargs: Any) -> None: ... + def setfetchsize(self, value: int) -> None: ... + def set_resultset_holdability(self, holdability: int) -> None: ... + def setoutputsize(self, *args: Any, **kwargs: Any) -> None: ... + +class Warning(Exception): + errorcode: int + errortext: str + +class Error(Exception): + errorcode: int + errortext: str + +class DatabaseError(Error): ... +class OperationalError(DatabaseError): ... +class ProgrammingError(DatabaseError): ... +class IntegrityError(DatabaseError): ... +class InterfaceError(Error): ... +class InternalError(DatabaseError): ... +class DataError(DatabaseError): ... +class NotSupportedError(DatabaseError): ... + +def Date(year: int, month: int, day: int) -> date: ... +def Time(hour: int, minute: int, second: int, millisecond: int = ...) -> time: ... +def Timestamp(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int = ...) -> datetime: ... +def DateFromTicks(ticks: float) -> date: ... +def TimeFromTicks(ticks: float) -> time: ... +def TimestampFromTicks(ticks: float) -> datetime: ... +def Binary(data: ReadableBuffer) -> memoryview: ... + +Decimal = decimal.Decimal + +NUMBER: Type[int] | Type[float] | Type[complex] +DATETIME: Type[date] | Type[time] | Type[datetime] +STRING = str +BINARY = memoryview +ROWID = int diff --git a/stubs/hdbcli/hdbcli/resultrow.pyi b/stubs/hdbcli/hdbcli/resultrow.pyi new file mode 100644 index 000000000..02a02eca9 --- /dev/null +++ b/stubs/hdbcli/hdbcli/resultrow.pyi @@ -0,0 +1,6 @@ +from typing import Any, Tuple + +class ResultRow: + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + column_names: Tuple[str, ...] + column_values: Tuple[Any, ...]