# Code generated by sqlc. DO NOT EDIT.
# versions:
#   sqlc v1.29.0
# source: kv_set_value.sql
import dataclasses

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


SET_VALUE = """-- name: set_value \\:exec
INSERT INTO hyrex_kv (key, value) 
VALUES (:p1, :p2)
ON CONFLICT (key) 
DO UPDATE SET value = EXCLUDED.value, created_at = CURRENT_TIMESTAMP
"""


@dataclasses.dataclass()
class SetValueParams:
    key: str
    value: str


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

    def set_value(self, arg: SetValueParams) -> None:
        self._conn.execute(sqlalchemy.text(SET_VALUE), {"p1": arg.key, "p2": arg.value})


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

    async def set_value(self, arg: SetValueParams) -> None:
        await self._conn.execute(sqlalchemy.text(SET_VALUE), {"p1": arg.key, "p2": arg.value})
