Пример #1
0
def count_snyk_table():
    connect_database()
    count = SNYK.select().count()
    if count:
        disconnect_database()
        return count
    return 0
Пример #2
0
def check_if_snyk_item_exists_in_postgres(item_in_json):
    connect_database()
    sid = -1
    snyks = []

    # if "cve_id" in item_in_json and "header_title" in item_in_json:
    # cve_id = item_in_json["cve_id"]
    # header_title = item_in_json["header_title"]
    if "snyk_id" in item_in_json:
        snyk_id = item_in_json["snyk_id"]
        snyks = list(SNYK.select().where(
            # (SNYK.cve_id == cve_id) & (SNYK.header_title == header_title) & (SNYK.snyk_id == snyk_id)
            (SNYK.snyk_id == snyk_id)))

    if len(snyks) == 0:
        disconnect_database()
        return False, sid
    else:
        sid = snyks[0].to_json["id"]
        disconnect_database()
        return True, sid