def sql_get_revenue(date, platform):
    TAG = "SQL_GET_DATE_LIST"

    sql = "SELECT sum(revenue) FROM ad_summary WHERE `date` = '%s' AND `platform` = '%s';" % (date, platform)
    mysql_config = config.mysql_config

    conn = toolkit.mysql_open_connection(mysql_config, TAG)
    if not conn:
        logging.error("SQL_GET_DATE_LIST:Error:mysql_open_connection")
        return None, False
    result, success = toolkit.mysql_query(conn, sql, TAG)
    logging.info("sql_get_revenue,result:%s" % result)
    toolkit.mysql_close_connection(conn)
    if not success or len(result) < 1:
        logging.error("SQL_GET_DATE_LIST:Fail:mysql_query")
        return None, False
    else:
        return result[0][0], True
Beispiel #2
0
def sql_get_date_list():
    TAG = "SQL_GET_DATE_LIST"
    date_list = []

    sql = "SELECT DISTINCT DATE FROM ad_summary;"
    mysql_config = config.mysql_config

    conn = toolkit.mysql_open_connection(mysql_config, TAG)
    if not conn:
        logging.error("SQL_GET_DATE_LIST:Error:mysql_open_connection")
        return None
    result, success = toolkit.mysql_query(conn, sql, TAG)
    toolkit.mysql_close_connection(conn)
    if not success:
        logging.error("SQL_GET_DATE_LIST:Fail:mysql_query")
        return None
    for r in result:
        date_list.append(r[0])
    print "date_list", date_list
    return date_list
Beispiel #3
0
def sql_get_platform_list():
    TAG = "SQL_GET_PLATFORM_LIST"
    platform_list = []

    sql = "SELECT DISTINCT platform FROM ad_summary;"
    mysql_config = config.mysql_config

    conn = toolkit.mysql_open_connection(mysql_config, TAG)
    if not conn:
        logging.error("SQL_GET_PLATFORM_LIST:Error:mysql_open_connection")
        return None
    result, success = toolkit.mysql_query(conn, sql, TAG)
    toolkit.mysql_close_connection(conn)
    # print "result", result
    if not success:
        logging.error("SQL_GET_PLATFORM_LIST:FAIL:mysql_query")
        return None
    for r in result:
        platform_list.append(r[0])
    print "platform_list", platform_list
    return platform_list