aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/db_helpers.py
blob: d4cc14868504352b067addec9e22001b175f10c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# SPDX-License-Identifier: BSD-3-Clause

"""Helpers for interpreting SQLAlchemy database results."""

from typing import Any, cast

from sqlalchemy.engine import CursorResult, Result


def rows_affected(result: Result[Any]) -> int:
    """Return the row count from a SQL UPDATE or DELETE result.

    :param result: SQLAlchemy result of an UPDATE or DELETE operation.
    :returns: Number of rows affected by the statement.
    """
    return cast(CursorResult[Any], result).rowcount