Skip to content

turu.sqlite3

turu.sqlite3.Connection

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
class Connection(turu.core.connection.Connection):
    def __init__(self, connection: sqlite3.Connection):
        self._raw_connection = connection

    @override
    @classmethod
    def connect(  # type: ignore[override]
        cls,
        database: Union[str, bytes],
        **kwargs: Unpack["_ConnectArgs"],
    ) -> Self:
        return cls(sqlite3.Connection(database, **kwargs))

    @override
    @classmethod
    def connect_from_env(cls, *args: Any, **kwargs: Any) -> Self:
        return cls.connect(*args, **kwargs)

    @override
    def close(self) -> None:
        self._raw_connection.close()

    @override
    def commit(self) -> None:
        self._raw_connection.commit()

    @override
    def rollback(self) -> None:
        self._raw_connection.rollback()

    @override
    def cursor(self) -> Cursor[Never]:
        return Cursor(self._raw_connection.cursor())

close()

Close the connection now.

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
@override
def close(self) -> None:
    self._raw_connection.close()

commit()

Commit any pending transaction to the database.

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
@override
def commit(self) -> None:
    self._raw_connection.commit()

connect(database, **kwargs) classmethod

Connect to a database.

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
@override
@classmethod
def connect(  # type: ignore[override]
    cls,
    database: Union[str, bytes],
    **kwargs: Unpack["_ConnectArgs"],
) -> Self:
    return cls(sqlite3.Connection(database, **kwargs))

connect_from_env(*args, **kwargs) classmethod

Connect to a database using environment variables.

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
@override
@classmethod
def connect_from_env(cls, *args: Any, **kwargs: Any) -> Self:
    return cls.connect(*args, **kwargs)

cursor()

Return a new Cursor Object using the connection.

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
@override
def cursor(self) -> Cursor[Never]:
    return Cursor(self._raw_connection.cursor())

rollback()

Roll back to the start of any pending transaction.

Closing a connection without committing the changes first will cause an implicit rollback to be performed.

Source code in turu-sqlite3/src/turu/sqlite3/connection.py
@override
def rollback(self) -> None:
    self._raw_connection.rollback()

turu.sqlite3.Cursor

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
class Cursor(
    turu.core.cursor.Cursor[turu.core.cursor.GenericRowType, "_Parameters"],
):
    def __init__(
        self,
        cursor: sqlite3.Cursor,
        *,
        row_type: Optional[Type[turu.core.cursor.GenericRowType]] = None,
    ):
        self._raw_cursor = cursor
        self._row_type: Optional[Type[turu.core.cursor.GenericRowType]] = row_type

    @property
    def rowcount(self) -> int:
        return self._raw_cursor.rowcount

    @property
    def arraysize(self) -> int:
        return self._raw_cursor.arraysize

    @arraysize.setter
    def arraysize(self, size: int) -> None:
        self._raw_cursor.arraysize = size

    @override
    def close(self) -> None:
        self._raw_cursor.close()

    @override
    def execute(
        self, operation: str, parameters: Optional["_Parameters"] = None, /
    ) -> "Cursor[Tuple[Any]]":
        self._raw_cursor.execute(operation, parameters or ())
        self._row_type = None

        return cast(Cursor, self)

    @override
    def executemany(
        self, operation: str, seq_of_parameters: "Sequence[_Parameters]", /
    ) -> "Cursor[Tuple[Any]]":
        self._raw_cursor.executemany(operation, seq_of_parameters)
        self._row_type = None

        return cast(Cursor, self)

    @override
    def execute_map(
        self,
        row_type: Type[turu.core.cursor.GenericNewRowType],
        operation: str,
        parameters: "Optional[_Parameters]" = None,
        /,
    ) -> "Cursor[turu.core.cursor.GenericNewRowType]":
        self._raw_cursor.execute(operation, parameters or ())
        self._row_type = cast(Type[turu.core.cursor.GenericRowType], row_type)

        return cast(Cursor, self)

    @override
    def executemany_map(
        self,
        row_type: Type[turu.core.cursor.GenericNewRowType],
        operation: str,
        seq_of_parameters: "Sequence[_Parameters]",
        /,
    ) -> "Cursor[turu.core.cursor.GenericNewRowType]":
        self._raw_cursor.executemany(operation, seq_of_parameters)
        self._row_type = cast(Type[turu.core.cursor.GenericRowType], row_type)

        return cast(Cursor, self)

    @override
    def execute_with_tag(
        self,
        tag: Type[turu.core.tag.Tag],
        operation: str,
        parameters: "Optional[_Parameters]" = None,
    ) -> "Cursor[Never]":
        return cast(Cursor, self.execute(operation, parameters))

    @override
    def executemany_with_tag(
        self,
        tag: Type[turu.core.tag.Tag],
        operation: str,
        seq_of_parameters: "Sequence[_Parameters]",
    ) -> "Cursor[Never]":
        return cast(Cursor, self.executemany(operation, seq_of_parameters))

    @override
    def fetchone(self) -> Optional[turu.core.cursor.GenericRowType]:
        row = self._raw_cursor.fetchone()
        if row is None:
            return None

        elif self._row_type is not None:
            return turu.core.cursor.map_row(self._row_type, row)

        else:
            return row

    @override
    def fetchmany(
        self, size: Optional[int] = None
    ) -> List[turu.core.cursor.GenericRowType]:
        return [
            turu.core.cursor.map_row(self._row_type, row)
            for row in (
                self._raw_cursor.fetchmany(size if size is not None else self.arraysize)
            )
        ]

    @override
    def fetchall(self) -> List[turu.core.cursor.GenericRowType]:
        return [
            turu.core.cursor.map_row(self._row_type, row)
            for row in self._raw_cursor.fetchall()
        ]

    @override
    def __next__(self) -> turu.core.cursor.GenericRowType:
        next_row = next(self._raw_cursor)
        if self._row_type is not None and next_row is not None:
            return turu.core.cursor.map_row(self._row_type, next_row)

        else:
            return next_row

arraysize: int property writable

The number of rows to fetch at a time with .fetchmany().

It defaults to 1 meaning to fetch a single row at a time.

rowcount: int property

The number of rows that the last .execute*() produced (for DQL statements like ) or affected (for DML statements like or ).

The attribute is -1 in case no .execute*() has been performed on the cursor or the rowcount of the last operation is cannot be determined by the interface.

execute(operation, parameters=None)

Prepare and execute a database operation (query or command).

Parameters:

Name Type Description Default
operation str

A database operation (query or command).

required
parameters Optional[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

None

Returns:

Type Description
Self

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def execute(
    self, operation: str, parameters: Optional["_Parameters"] = None, /
) -> "Cursor[Tuple[Any]]":
    self._raw_cursor.execute(operation, parameters or ())
    self._row_type = None

    return cast(Cursor, self)

execute_map(row_type, operation, parameters=None)

Execute a database operation (query or command) and map each row to a row_type.

Parameters:

Name Type Description Default
row_type Type[GenericNewRowType]

The type of the row that will be returned.

required
operation str

A database operation (query or command).

required
parameters Optional[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

None

Returns:

Type Description
Cursor[GenericNewRowType, Parameters]

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def execute_map(
    self,
    row_type: Type[turu.core.cursor.GenericNewRowType],
    operation: str,
    parameters: "Optional[_Parameters]" = None,
    /,
) -> "Cursor[turu.core.cursor.GenericNewRowType]":
    self._raw_cursor.execute(operation, parameters or ())
    self._row_type = cast(Type[turu.core.cursor.GenericRowType], row_type)

    return cast(Cursor, self)

execute_with_tag(tag, operation, parameters=None)

Execute a database operation (Insert, Update, Delete) with a tag.

This is not defined in PEP 249,

This method is provided for testing, and is intended to be used in conjunction with MockConnection.inject_operation_with_tag.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def execute_with_tag(
    self,
    tag: Type[turu.core.tag.Tag],
    operation: str,
    parameters: "Optional[_Parameters]" = None,
) -> "Cursor[Never]":
    return cast(Cursor, self.execute(operation, parameters))

executemany(operation, seq_of_parameters)

Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings.

Parameters:

Name Type Description Default
operation str

A database operation (query or command).

required
seq_of_parameters Sequence[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

required

Returns:

Type Description
Self

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def executemany(
    self, operation: str, seq_of_parameters: "Sequence[_Parameters]", /
) -> "Cursor[Tuple[Any]]":
    self._raw_cursor.executemany(operation, seq_of_parameters)
    self._row_type = None

    return cast(Cursor, self)

executemany_map(row_type, operation, seq_of_parameters)

Execute a database operation (query or command) against all parameter sequences or mappings.

Parameters:

Name Type Description Default
row_type Type[GenericNewRowType]

The type of the row that will be returned.

required
operation str

A database operation (query or command).

required
seq_of_parameters Sequence[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

required

Returns:

Type Description
Cursor[GenericNewRowType, Parameters]

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def executemany_map(
    self,
    row_type: Type[turu.core.cursor.GenericNewRowType],
    operation: str,
    seq_of_parameters: "Sequence[_Parameters]",
    /,
) -> "Cursor[turu.core.cursor.GenericNewRowType]":
    self._raw_cursor.executemany(operation, seq_of_parameters)
    self._row_type = cast(Type[turu.core.cursor.GenericRowType], row_type)

    return cast(Cursor, self)

executemany_with_tag(tag, operation, seq_of_parameters)

Execute a database operation (Insert, Update, Delete) against all parameter sequences or mappings with a tag.

This is not defined in PEP 249,

This method is provided for testing, and is intended to be used in conjunction with MockConnection.inject_operation_with_tag.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def executemany_with_tag(
    self,
    tag: Type[turu.core.tag.Tag],
    operation: str,
    seq_of_parameters: "Sequence[_Parameters]",
) -> "Cursor[Never]":
    return cast(Cursor, self.executemany(operation, seq_of_parameters))

fetchall()

Fetch all (remaining) rows of a query result

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def fetchall(self) -> List[turu.core.cursor.GenericRowType]:
    return [
        turu.core.cursor.map_row(self._row_type, row)
        for row in self._raw_cursor.fetchall()
    ]

fetchmany(size=None)

Fetch the next set of rows of a query result.

An empty sequence is returned when no more rows are available.

Parameters:

Name Type Description Default
size Optional[int]

The number of rows to fetch per call. If this parameter is not used, it is usually refer to use the .arraysize attribute (Default is 1). If this parameter is used, then it is best for it to retain the same value from one .fetchmany() call to the next.

None
Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def fetchmany(
    self, size: Optional[int] = None
) -> List[turu.core.cursor.GenericRowType]:
    return [
        turu.core.cursor.map_row(self._row_type, row)
        for row in (
            self._raw_cursor.fetchmany(size if size is not None else self.arraysize)
        )
    ]

fetchone()

Fetch the next row of a query result set.

Source code in turu-sqlite3/src/turu/sqlite3/cursor.py
@override
def fetchone(self) -> Optional[turu.core.cursor.GenericRowType]:
    row = self._raw_cursor.fetchone()
    if row is None:
        return None

    elif self._row_type is not None:
        return turu.core.cursor.map_row(self._row_type, row)

    else:
        return row

turu.sqlite3.AsyncConnection

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
class AsyncConnection(turu.core.async_connection.AsyncConnection):
    def __init__(self, connection: aiosqlite.Connection):
        self._raw_connection = connection

    @override
    @classmethod
    async def connect(  # type: ignore[override]
        cls,
        database: Union[str, Path],
        *,
        iter_chunk_size: int = 64,
        **kwargs: Unpack[_ConnectArgs],
    ) -> Self:
        return cls(
            await aiosqlite.connect(
                database,
                iter_chunk_size=iter_chunk_size,
                loop=None,
                **kwargs,
            )
        )

    @override
    @classmethod
    async def connect_from_env(cls, *args: Any, **kwargs: Any) -> Self:
        return await cls.connect(*args, **kwargs)

    @override
    async def close(self) -> None:
        await self._raw_connection.close()

    @override
    async def commit(self) -> None:
        await self._raw_connection.commit()

    @override
    async def rollback(self) -> None:
        await self._raw_connection.rollback()

    @override
    async def cursor(self) -> AsyncCursor[Never]:
        return AsyncCursor(await self._raw_connection.cursor())

close() async

Close the connection now.

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
@override
async def close(self) -> None:
    await self._raw_connection.close()

commit() async

Commit any pending transaction to the database.

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
@override
async def commit(self) -> None:
    await self._raw_connection.commit()

connect(database, *, iter_chunk_size=64, **kwargs) async classmethod

Connect to a database.

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
@override
@classmethod
async def connect(  # type: ignore[override]
    cls,
    database: Union[str, Path],
    *,
    iter_chunk_size: int = 64,
    **kwargs: Unpack[_ConnectArgs],
) -> Self:
    return cls(
        await aiosqlite.connect(
            database,
            iter_chunk_size=iter_chunk_size,
            loop=None,
            **kwargs,
        )
    )

connect_from_env(*args, **kwargs) async classmethod

Connect to a database using environment variables.

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
@override
@classmethod
async def connect_from_env(cls, *args: Any, **kwargs: Any) -> Self:
    return await cls.connect(*args, **kwargs)

cursor() async

Return a new Cursor Object using the connection.

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
@override
async def cursor(self) -> AsyncCursor[Never]:
    return AsyncCursor(await self._raw_connection.cursor())

rollback() async

Roll back to the start of any pending transaction.

Closing a connection without committing the changes first will cause an implicit rollback to be performed.

Source code in turu-sqlite3/src/turu/sqlite3/async_connection.py
@override
async def rollback(self) -> None:
    await self._raw_connection.rollback()

turu.sqlite3.AsyncCursor

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
class AsyncCursor(
    turu.core.async_cursor.AsyncCursor[
        turu.core.async_cursor.GenericRowType, Iterator[Any]
    ],
):
    def __init__(
        self,
        cursor: aiosqlite.Cursor,
        *,
        row_type: Optional[Type[turu.core.async_cursor.GenericRowType]] = None,
    ):
        self._raw_cursor = cursor
        self._row_type: Optional[Type[turu.core.async_cursor.GenericRowType]] = row_type
        self._aiter = None

    @property
    def rowcount(self) -> int:
        return self._raw_cursor.rowcount

    @property
    def arraysize(self) -> int:
        return self._raw_cursor.arraysize

    @arraysize.setter
    def arraysize(self, size: int) -> None:
        self._raw_cursor.arraysize = size

    @override
    async def close(self) -> None:
        await self._raw_cursor.close()

    @override
    async def execute(
        self, operation: str, parameters: Optional["Iterator[Any]"] = None, /
    ) -> "AsyncCursor[Tuple[Any]]":
        await self._raw_cursor.execute(operation, parameters)
        self._row_type = None

        return cast(AsyncCursor, self)

    @override
    async def executemany(
        self, operation: str, seq_of_parameters: "Sequence[Iterator[Any]]", /
    ) -> "AsyncCursor[Tuple[Any]]":
        await self._raw_cursor.executemany(operation, seq_of_parameters)
        self._row_type = None

        return cast(AsyncCursor, self)

    @override
    async def execute_map(
        self,
        row_type: Type[turu.core.async_cursor.GenericNewRowType],
        operation: str,
        parameters: "Optional[Iterator[Any]]" = None,
        /,
    ) -> "AsyncCursor[turu.core.async_cursor.GenericNewRowType]":
        await self._raw_cursor.execute(operation, parameters)
        self._row_type = cast(Type[turu.core.async_cursor.GenericRowType], row_type)

        return cast(AsyncCursor, self)

    @override
    async def executemany_map(
        self,
        row_type: Type[turu.core.async_cursor.GenericNewRowType],
        operation: str,
        seq_of_parameters: "Sequence[Iterator[Any]]",
        /,
    ) -> "AsyncCursor[turu.core.async_cursor.GenericNewRowType]":
        await self._raw_cursor.executemany(operation, seq_of_parameters)
        self._row_type = cast(Type[turu.core.async_cursor.GenericRowType], row_type)

        return cast(AsyncCursor, self)

    @override
    async def execute_with_tag(
        self,
        tag: Type[turu.core.tag.Tag],
        operation: str,
        parameters: "Optional[Iterator[Any]]" = None,
    ) -> turu.core.async_cursor.AsyncCursor[Never, Iterator[Any]]:
        return cast(
            turu.core.async_cursor.AsyncCursor,
            await self.execute(operation, parameters),
        )

    @override
    async def executemany_with_tag(
        self,
        tag: Type[turu.core.tag.Tag],
        operation: str,
        seq_of_parameters: Sequence[Iterator[Any]],
    ) -> turu.core.async_cursor.AsyncCursor[Never, Iterator[Any]]:
        return cast(
            turu.core.async_cursor.AsyncCursor,
            await self.executemany(operation, seq_of_parameters),
        )

    @override
    async def fetchone(self) -> Optional[turu.core.async_cursor.GenericRowType]:
        row = await self._raw_cursor.fetchone()
        if row is None:
            return None

        return _map_row(self._row_type, row)

    @override
    async def fetchmany(
        self, size: Optional[int] = None
    ) -> List[turu.core.async_cursor.GenericRowType]:
        return [
            _map_row(self._row_type, row)
            for row in (
                await self._raw_cursor.fetchmany(
                    size if size is not None else self.arraysize
                )
            )
        ]

    @override
    async def fetchall(self) -> List[turu.core.async_cursor.GenericRowType]:
        return [
            _map_row(self._row_type, row) for row in await self._raw_cursor.fetchall()
        ]

    @override
    def __aiter__(self) -> "AsyncCursor[turu.core.async_cursor.GenericRowType]":
        self._aiter = self._raw_cursor.__aiter__()
        return self

    @override
    async def __anext__(self) -> turu.core.async_cursor.GenericRowType:
        if self._aiter is None:
            self._aiter = self._raw_cursor.__aiter__()

        next_row = await self._aiter.__anext__()
        return _map_row(self._row_type, next_row)

arraysize: int property writable

This read/write attribute specifies the number of rows to fetch at a time with .fetchmany(). It defaults to 1 meaning to fetch a single row at a time.

Implementations must observe this value with respect to the .fetchmany() method, but are free to interact with the database a single row at a time. It may also be used in the implementation of .executemany().

rowcount: int property

the number of rows that the last .execute*() produced (for DQL statements like ) or affected (for DML statements like or ).

The attribute is -1 in case no .execute*() has been performed on the cursor or the rowcount of the last operation is cannot be determined by the interface.

execute(operation, parameters=None) async

Prepare and execute a database operation (query or command).

Parameters:

Name Type Description Default
operation str

A database operation (query or command).

required
parameters Optional[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

None

Returns:

Type Description
Self

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def execute(
    self, operation: str, parameters: Optional["Iterator[Any]"] = None, /
) -> "AsyncCursor[Tuple[Any]]":
    await self._raw_cursor.execute(operation, parameters)
    self._row_type = None

    return cast(AsyncCursor, self)

execute_map(row_type, operation, parameters=None) async

Execute a database operation (query or command) and map each row to a row_type.

Parameters:

Name Type Description Default
row_type Type[GenericNewRowType]

The type of the row that will be returned.

required
operation str

A database operation (query or command).

required
parameters Optional[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

None

Returns:

Type Description
AsyncCursor[GenericNewRowType, Parameters]

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def execute_map(
    self,
    row_type: Type[turu.core.async_cursor.GenericNewRowType],
    operation: str,
    parameters: "Optional[Iterator[Any]]" = None,
    /,
) -> "AsyncCursor[turu.core.async_cursor.GenericNewRowType]":
    await self._raw_cursor.execute(operation, parameters)
    self._row_type = cast(Type[turu.core.async_cursor.GenericRowType], row_type)

    return cast(AsyncCursor, self)

execute_with_tag(tag, operation, parameters=None) async

Execute a database operation (Insert, Update, Delete) with a tag.

This is not defined in PEP 249,

This method executes an operation (Insert, Update, Delete) that does not return a value with a tag. This tag is used to verify that the specified operation is executed in order when testing with Mock.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def execute_with_tag(
    self,
    tag: Type[turu.core.tag.Tag],
    operation: str,
    parameters: "Optional[Iterator[Any]]" = None,
) -> turu.core.async_cursor.AsyncCursor[Never, Iterator[Any]]:
    return cast(
        turu.core.async_cursor.AsyncCursor,
        await self.execute(operation, parameters),
    )

executemany(operation, seq_of_parameters) async

Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings.

Parameters:

Name Type Description Default
operation str

A database operation (query or command).

required
seq_of_parameters Sequence[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

required

Returns:

Type Description
Self

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def executemany(
    self, operation: str, seq_of_parameters: "Sequence[Iterator[Any]]", /
) -> "AsyncCursor[Tuple[Any]]":
    await self._raw_cursor.executemany(operation, seq_of_parameters)
    self._row_type = None

    return cast(AsyncCursor, self)

executemany_map(row_type, operation, seq_of_parameters) async

Execute a database operation (query or command) against all parameter sequences or mappings.

Parameters:

Name Type Description Default
row_type Type[GenericNewRowType]

The type of the row that will be returned.

required
operation str

A database operation (query or command).

required
seq_of_parameters Sequence[Parameters]

Parameters may be provided as sequence or mapping and will be bound to variables in the operation.

required

Returns:

Type Description
AsyncCursor[GenericNewRowType, Parameters]

A cursor that holds a reference to an operation.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def executemany_map(
    self,
    row_type: Type[turu.core.async_cursor.GenericNewRowType],
    operation: str,
    seq_of_parameters: "Sequence[Iterator[Any]]",
    /,
) -> "AsyncCursor[turu.core.async_cursor.GenericNewRowType]":
    await self._raw_cursor.executemany(operation, seq_of_parameters)
    self._row_type = cast(Type[turu.core.async_cursor.GenericRowType], row_type)

    return cast(AsyncCursor, self)

executemany_with_tag(tag, operation, seq_of_parameters) async

Execute a database operation (Insert, Update, Delete) against all parameter sequences or mappings with a tag.

This is not defined in PEP 249,

This method executes an operation (Insert, Update, Delete) that does not return a value with a tag. This tag is used to verify that the specified operation is executed in order when testing with Mock.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def executemany_with_tag(
    self,
    tag: Type[turu.core.tag.Tag],
    operation: str,
    seq_of_parameters: Sequence[Iterator[Any]],
) -> turu.core.async_cursor.AsyncCursor[Never, Iterator[Any]]:
    return cast(
        turu.core.async_cursor.AsyncCursor,
        await self.executemany(operation, seq_of_parameters),
    )

fetchall() async

Fetch all (remaining) rows of a query result

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def fetchall(self) -> List[turu.core.async_cursor.GenericRowType]:
    return [
        _map_row(self._row_type, row) for row in await self._raw_cursor.fetchall()
    ]

fetchmany(size=None) async

Fetch the next set of rows of a query result.

An empty sequence is returned when no more rows are available.

Parameters:

Name Type Description Default
size Optional[int]

The number of rows to fetch per call. If this parameter is not used, it is usually refer to use the .arraysize attribute (Default is 1). If this parameter is used, then it is best for it to retain the same value from one .fetchmany() call to the next.

None
Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def fetchmany(
    self, size: Optional[int] = None
) -> List[turu.core.async_cursor.GenericRowType]:
    return [
        _map_row(self._row_type, row)
        for row in (
            await self._raw_cursor.fetchmany(
                size if size is not None else self.arraysize
            )
        )
    ]

fetchone() async

Fetch the next row of a query result set.

Source code in turu-sqlite3/src/turu/sqlite3/async_cursor.py
@override
async def fetchone(self) -> Optional[turu.core.async_cursor.GenericRowType]:
    row = await self._raw_cursor.fetchone()
    if row is None:
        return None

    return _map_row(self._row_type, row)