from asyncio import AbstractEventLoop
from typing import Any

from . import Connection, ResultSet, Row

async def connect_async(
    conninfo: str, loop: AbstractEventLoop | None = ...,
) -> AsyncConnection: ...

class AsyncConnection:
    cnxn: Connection

    @property
    def transaction_status(self) -> int: ...
    @property
    def server_version(self) -> int: ...
    @property
    def protocol_version(self) -> int: ...
    @property
    def server_encoding(self) -> str: ...
    @property
    def client_encoding(self) -> str: ...
    @property
    def status(self) -> bool: ...

    async def execute(self, sql: str, *params: Any) -> ResultSet | int | None: ...
    async def fetchrow(self, sql: str, *params: Any) -> Row | None: ...
    async def fetchval(self, sql: str, *params: Any) -> Any: ...
    async def fetchvals(self, sql: str, *params: Any) -> list[Any]: ...
    async def script(self, sql: str) -> None: ...

    async def listen(self, *channels: str) -> None: ...
    async def notify(self, channel: str, payload: str | None = ...) -> None: ...
    async def notifications(self, timeout: float | None = ...) -> list[tuple[str, str | None]]: ...

    async def begin(self) -> None: ...
    async def commit(self) -> None: ...
    async def rollback(self) -> None: ...

    def close(self) -> None: ...
