Skip to content

Commit

Permalink
Add CLI population command for DB
Browse files Browse the repository at this point in the history
  • Loading branch information
john681611 committed Sep 14, 2023
1 parent d93b3c6 commit 6296b77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions application/cmd/cre_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ def run(args: argparse.Namespace) -> None: # pragma: no cover
generate_embeddings(args.cache_file)
if args.owasp_proj_meta:
owasp_metadata_to_cre(args.owasp_proj_meta)
if args.populate_neo4j_db:
populate_neo4j_db(args.cache_file)


def db_connect(path: str):
Expand Down Expand Up @@ -530,3 +532,10 @@ def owasp_metadata_to_cre(meta_file: str):
},
"""
raise NotImplementedError("someone needs to work on this")

def populate_neo4j_db(cache: str):
logger.info(f"Populating neo4j DB: Connecting to SQL DB")
database = db_connect(path=cache)
logger.info(f"Populating neo4j DB: Populating")
database.neo_db.populate_DB(database.session)
logger.info(f"Populating neo4j DB: Complete")
6 changes: 6 additions & 0 deletions cre.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ def main() -> None:
action="store_true",
help="for every node, download the text pointed to by the hyperlink and generate embeddings for the content of the specific node",
)
parser.add_argument(
"--populate_neo4j_db",
action="store_true",
help="populate the neo4j db",
)


args = parser.parse_args()

Expand Down

0 comments on commit 6296b77

Please sign in to comment.