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

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


CREATE_CRON_JOB_FOR_TASK = """-- name: create_cron_job_for_task \\:exec
INSERT INTO hyrex_cron_job (schedule, command, jobname, job_source)
VALUES (:p1, :p2, :p3, 'TASK')
ON CONFLICT (jobname) 
DO UPDATE SET 
    schedule = EXCLUDED.schedule,
    command = EXCLUDED.command,
    job_source = 'TASK',
    active = true
"""


@dataclasses.dataclass()
class CreateCronJobForTaskParams:
    schedule: Optional[str]
    command: str
    jobname: str


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

    def create_cron_job_for_task(self, arg: CreateCronJobForTaskParams) -> None:
        self._conn.execute(sqlalchemy.text(CREATE_CRON_JOB_FOR_TASK), {"p1": arg.schedule, "p2": arg.command, "p3": arg.jobname})


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

    async def create_cron_job_for_task(self, arg: CreateCronJobForTaskParams) -> None:
        await self._conn.execute(sqlalchemy.text(CREATE_CRON_JOB_FOR_TASK), {"p1": arg.schedule, "p2": arg.command, "p3": arg.jobname})
