Example #1
0
def get_all_count(doc_type):

    cursor = get_mysql_connection_cursor()
    sql = 'SELECT COUNT(1) FROM t_index_article WHERE `doc_type` = %s'
    p = (doc_type, )
    cursor.execute(sql, p)
    rows = cursor.fetchone()
    return rows[0]
Example #2
0
def get_data_by_page(page_num, page_size, doc_type):

    cursor = get_mysql_connection_cursor()
    sql = 'select `doc_id`, `attitude_index`, `sentiment`, `heat` ' \
          'from `t_index_article` ' \
          'where `pt` > "2020-12-09 23:49:03" and `doc_type` = %(doc_type)s ' \
          'limit %(page_num)s, %(page_size)s '
    p = {"page_num": page_num, "page_size": page_size, "doc_type": doc_type}
    cursor.execute(sql, p)
    rows = cursor.fetchall()
    return rows