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

import sqlalchemy
import sqlalchemy.ext.asyncio

from . import models


CREATE_CRON_JOB_FOR_SQL_QUERY = """-- name: create_cron_job_for_sql_query \\:exec
INSERT INTO hyrex_cron_job (schedule, command, jobname, should_backfill, job_source)
VALUES (:p1, :p2, :p3, :p4, 'SYSTEM')
ON CONFLICT (jobname) 
DO UPDATE SET 
    schedule = EXCLUDED.schedule,
    command = EXCLUDED.command,
    should_backfill = EXCLUDED.should_backfill,
    job_source = 'SYSTEM',
    active = true
"""


@dataclasses.dataclass()
class CreateCronJobForSqlQueryParams:
    schedule: Optional[str]
    command: str
    jobname: str
    should_backfill: Optional[bool]


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

    def create_cron_job_for_sql_query(self, arg: CreateCronJobForSqlQueryParams) -> None:
        self._conn.execute(sqlalchemy.text(CREATE_CRON_JOB_FOR_SQL_QUERY), {
            "p1": arg.schedule,
            "p2": arg.command,
            "p3": arg.jobname,
            "p4": arg.should_backfill,
        })


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

    async def create_cron_job_for_sql_query(self, arg: CreateCronJobForSqlQueryParams) -> None:
        await self._conn.execute(sqlalchemy.text(CREATE_CRON_JOB_FOR_SQL_QUERY), {
            "p1": arg.schedule,
            "p2": arg.command,
            "p3": arg.jobname,
            "p4": arg.should_backfill,
        })
