adio_dao.py 1013 Bytes
Newer Older
lcn's avatar
lcn committed
1 2 3 4 5
from pot_libs.mysql_util.mysql_util import MysqlUtil


async def get_location_dao(lids):
    location_info = {}
lcn's avatar
lcn committed
6
    sql = "SELECT lid, item, mtid, ad_type FROM location WHERE lid IN %s"
lcn's avatar
lcn committed
7 8 9 10 11 12 13
    async with MysqlUtil() as conn:
        result = await conn.fetchall(sql, args=(lids,))
        if result:
            for res in result:
                id = res.get("lid")
                item = res.get("item")
                type = res.get("ad_type")
lcn's avatar
lcn committed
14 15
                mtid = res.get("mtid")
                location_info[id] = {"item": item, "type": type, "mtid": mtid}
lcn's avatar
lcn committed
16 17 18
    return location_info


lcn's avatar
lcn committed
19 20
async def get_location_15min_dao(lid, start, end,
                                 table_name="location_15min_aiao"):
lcn's avatar
lcn committed
21
    sql = f"SELECT lid,value_max,value_max_time,value_avg,value_min," \
lcn's avatar
lcn committed
22
          f"value_min_time  FROM {table_name} WHERE lid = %s " \
lcn's avatar
lcn committed
23 24 25 26
          f"and create_time BETWEEN '{start}' and '{end}'"
    async with MysqlUtil() as conn:
        result = await conn.fetchall(sql, args=(lid,))
    return result