from pot_libs.mysql_util.mysql_util import MysqlUtil


async def get_kwh_p_dao(table_name, terms, start, end):
    sql = f"SELECT create_time,kwh,p FROM {table_name} WHERE cid in %s " \
          f"and create_time BETWEEN '{start}' and '{end}'"
    async with MysqlUtil() as conn:
        datas = await conn.fetchall(sql, args=(terms, ))
    return datas


async def get_pred_p_dao(terms, start, end):
    sql = f"SELECT create_time,p FROM company_day_ahead_predict " \
          f"WHERE cid in %s and create_time BETWEEN '{start}' and '{end}'"
    async with MysqlUtil() as conn:
        datas = await conn.fetchall(sql, args=(terms,))
    return datas