# Code generated by sqlc. DO NOT EDIT.
# versions:
#   sqlc v1.29.0
# source: save_result.sql
import dataclasses
from typing import Any, Optional
import uuid

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


SAVE_RESULT = """-- name: save_result \\:exec
INSERT INTO hyrex_task_result
    (task_id, result)
VALUES (:p1, :p2)
"""


@dataclasses.dataclass()
class SaveResultParams:
    task_id: uuid.UUID
    result: Optional[Any]


class Querier:
    def __init__(self, conn: sqlalchemy.engine.Connection):
        self._conn = conn

    def save_result(self, arg: SaveResultParams) -> None:
        self._conn.execute(sqlalchemy.text(SAVE_RESULT), {"p1": arg.task_id, "p2": arg.result})


class AsyncQuerier:
    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
        self._conn = conn

    async def save_result(self, arg: SaveResultParams) -> None:
        await self._conn.execute(sqlalchemy.text(SAVE_RESULT), {"p1": arg.task_id, "p2": arg.result})
