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

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


GET_VALUE = """-- name: get_value \\:one
SELECT value FROM hyrex_kv WHERE key = :p1
"""


@dataclasses.dataclass()
class GetValueParams:
    key: str


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

    def get_value(self, arg: GetValueParams) -> Optional[str]:
        row = self._conn.execute(sqlalchemy.text(GET_VALUE), {"p1": arg.key}).first()
        if row is None:
            return None
        return row[0]


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

    async def get_value(self, arg: GetValueParams) -> Optional[str]:
        row = (await self._conn.execute(sqlalchemy.text(GET_VALUE), {"p1": arg.key})).first()
        if row is None:
            return None
        return row[0]
