Skip to content

Commit

Permalink
Store to sqlite
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Mar 17, 2024
1 parent e18c9d6 commit 5210b26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions vdb/lib/cve.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import pickle
import uuid

import orjson
Expand Down Expand Up @@ -364,12 +363,12 @@ def store5(self, data: list[CVE]):
exclude_unset=True,
exclude_none=True)
self.db_conn.execute(
"INSERT INTO cve_data values(?, ?, ?, ?, ?, ?);", (
"INSERT INTO cve_data values(?, ?, ?, ?, json(?), ?);", (
cve_id,
affected.vendor,
affected.product,
affected.packageName,
pickle.dumps(source_data),
orjson.dumps(source_data).decode("utf-8", "ignore"),
None))
cleaned_versions = [v.model_dump(mode="json", exclude_none=True) for v in versions]
self.index_conn.execute(
Expand Down
2 changes: 1 addition & 1 deletion vdb/lib/db6.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def ensure_schemas(db_conn: sqlite3.Connection, index_conn: sqlite3.Connection):
"""Create the sqlite tables and indexes in case they don't exist"""
db_conn.execute(
"CREATE TABLE if not exists cve_data(cve_id TEXT NOT NULL, type TEXT NOT NULL, namespace TEXT, name TEXT NOT NULL, source_data BLOB NOT NULL, override_data BLOB);")
"CREATE TABLE if not exists cve_data(cve_id TEXT NOT NULL, type TEXT NOT NULL, namespace TEXT, name TEXT NOT NULL, source_data JSON NOT NULL, override_data JSON);")
db_conn.execute(
"CREATE INDEX if not exists idx1 on cve_data(cve_id, type);")
index_conn.execute(
Expand Down

0 comments on commit 5210b26

Please sign in to comment.