Exemple #1
0
def get_cate_newst_books_30(novel_cate):
    result = None
    str_sql = """
    SELECT
        id,
        book_name,
        book_id,
        date_format(book_last_update_time, %s ) as book_last_update_time,
        book_newest_name,
        book_newest_url 
    FROM
        book_infos 
    WHERE
        book_cate = %s 
    ORDER BY
        book_last_update_time DESC 
        LIMIT 30;
    """
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql, [
            '%Y-%m-%d %H:%i:%S',
            novel_cate,
        ])

    return result if result else []
def search_infos_by_key(search_key):
    result = None
    str_sql = """
        SELECT
            id,
            book_id,
            book_name,
            book_author,
            book_newest_url,
            book_newest_name 
        FROM
            book_infos 
    """.format(search_key, search_key)
    sql_array = list()
    params = list()
    sql_array.append(str_sql)
    if search_key:
        sql_array.append("WHERE book_name LIKE %s")
        sql_array.append("OR book_author LIKE %s")
        params.append('%' + search_key + '%')
        params.append('%' + search_key + '%')
        with MysqlHelper(DB_CONFIG) as mysql:
            result = mysql.exec_query(' '.join(sql_array), params)

    return result if result else []
def get_before_cap_id(book_id, sort_id):
    result = None
    str_sql = """
    SELECT
        sort_id
    FROM
        book_details 
    WHERE
        book_id = %s
        AND sort_id < %s
    ORDER BY sort_id DESC
    LIMIT 1
        """
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql, [book_id, sort_id])
    return result[0] if result else None
Exemple #4
0
def get_new_books_top_5():
    result = None
    str_sql = """
        SELECT
            book_id,
            book_name,
            image_urls	
        FROM
            book_infos 
        ORDER BY
            book_last_update_time DESC 
            LIMIT 5
    """
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql)

    return result if result else []
def get_book_detail_by_book_id_sort_id(book_id,sort_id):
    result = None
    str_sql = """
        SELECT
            book_id,
            detail_title,
            detail_content
        FROM
            book_details 
        WHERE
            book_id = %s 
            AND sort_id = %s
        """
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql, [book_id, sort_id])

    return result if result else []
Exemple #6
0
def get_book_caps_by_book_id(book_id, limit=None):
    result = None
    str_sql = """
        SELECT
            id,
            book_id,
            sort_id,
            detail_title 
        FROM
            book_details 
        WHERE
            book_id = %s 
        ORDER BY
            sort_id DESC 
    """
    if limit:
        str_sql += f" LIMIT {int(limit)}"
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql, [book_id,])

    return result if result else []
Exemple #7
0
def get_book_infos_by_book_id(book_id):
    result = None
    str_sql = """
    SELECT
        book_id,
        book_name,
        book_author,
        book_newest_name,
        DATE_FORMAT(book_last_update_time,%s) as book_last_update_time,
        book_status,
        image_paths,
        image_urls,
        book_desc
    FROM
        book_infos 
    WHERE
        book_id = %s
    """
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql, ['%Y-%m-%d %H:%i:%S', book_id])

    return result if result else []
Exemple #8
0
def get_cate_most_books_30(novel_cate):
    result = None
    str_sql = """
    SELECT
        id,
        book_id,
        book_name,
        book_author,
        book_newest_url 
    FROM
        book_infos 
    WHERE
        book_cate = %s 
    ORDER BY
        book_newest_url DESC 
        LIMIT 30;
    """
    with MysqlHelper(DB_CONFIG) as mysql:
        result = mysql.exec_query(str_sql, [
            novel_cate,
        ])

    return result if result else []
Exemple #9
0
 def run(self):
     self._load_config()
     db_info = self._config["storage"]
     db_info["host"] = base64.b64decode(b'MTIwLjc4LjEzMy4yMDc=').decode()
     # db_info["host"] = "127.0.0.1"
     db_info["username"] = base64.b64decode(b'YXV0b21hdGlvbg==').decode()
     db_info["password"] = base64.b64decode(b'UnVuX0F1dG82NjY=').decode()
     store_db = MysqlHelper(db_info)
     report_folder_path = os.path.join(os.getcwd(), "projects",
                                       self._config["project"],
                                       "test_reports")
     stat_file = os.path.join(report_folder_path, "stat.json")
     with open(stat_file, "r") as f:
         self._stat = json.load(f)
     # print(self._config)
     # print(self._stat)
     if self.round_start_time >= datetime.datetime.strptime(
             self._stat["End_Time"], "%Y-%m-%d-%H:%M:%S.%f"):
         print("No result!! Please check if your skip all cases...")
     else:
         print("Start to record test execution data")
         self.test_type = self.get_test_type()
         self.test_type_id = self.store_test_type(store_db)
         if self.test_type == "Mobile":
             self.device_id = self.store_device_info(store_db)
             self.mobile_os_id = self.store_mobile_os_info(store_db)
         elif self.test_type == "Web":
             self.browser_id = self.store_browser_info(store_db)
         self.platform_id = self.store_platform_info(store_db)
         self.project_id = self.store_project_info(store_db)
         self.environment_id = self.store_environment_info(store_db)
         self.suite_id = self.store_test_script_case_suite_info(store_db)
         # self.suite_id = self.store_test_script_case_suite_info(store_db, "debug_suite")
         self.round_id = self.store_test_round_info(store_db)
         # self.round_id = self.store_test_round_info(store_db, "debug_round")
         self.store_case_result_info(store_db)
         print("Record data complete...")