Here are the examples of the python api sqlalchemy.join.outerjoin taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
View Complete Implementation : crawl_patches.py
Copyright Apache License 2.0
Author : google
Copyright Apache License 2.0
Author : google
def get_nvd_github_patch_candidates():
"""Fetches concrete github.com commit links from the Nvd database.
:return:
"""
patch_regex = r"github\.com/([^/]+)/([^/]+)/commit/([^/]+)"
sub_query = (db.session.query(func.min(Reference.id)).filter(
Reference.link.op("regexp")(patch_regex)).group_by(
Reference.nvd_json_id))
github_commit_candidates = (db.session.query(
Nvd.cve_id, Reference.link, Vulnerability).select_from(
join(Nvd, Reference).outerjoin(
Vulnerability, Nvd.cve_id == Vulnerability.cve_id)).filter(
Reference.id.in_(sub_query)).with_labels())
return github_commit_candidates
3
View Complete Implementation : crawl_patches.py
Copyright Apache License 2.0
Author : google
Copyright Apache License 2.0
Author : google
def create_oss_entries():
nvd_entries = db.session.query(Nvd.cve_id, Vulnerability)
nvd_entries = nvd_entries.select_from(
join(Nvd,
Cpe).outerjoin(Vulnerability,
Nvd.cve_id == Vulnerability.cve_id)).with_labels()
nvd_entries = nvd_entries.filter(Vulnerability.cve_id.is_(None))
# nvd_entries = nvd_entries.options(default_nvd_view_options)
nvd_entries = nvd_entries.join(
OpenSourceProducts,
and_(Cpe.vendor == OpenSourceProducts.vendor,
Cpe.product == OpenSourceProducts.product))
nvd_entries = nvd_entries.distinct(Nvd.cve_id)
return nvd_entries
0
View Complete Implementation : crawl_patches.py
Copyright Apache License 2.0
Author : google
Copyright Apache License 2.0
Author : google
def update_oss_table():
# Fetch all distinct vendor, product tuples from the main table.
unique_products = db.session.query(Cpe.vendor, Cpe.product)
unique_products = unique_products.select_from(
join(Nvd, Cpe).outerjoin(Vulnerability,
Vulnerability.cve_id == Nvd.cve_id))
unique_products = unique_products.filter(Vulnerability.cve_id.isnot(None))
unique_products = unique_products.distinct(Cpe.vendor, Cpe.product)
# Fetch only entries which are not already contained in OpenSourceProducts.
unique_products = unique_products.outerjoin(
OpenSourceProducts,
and_(Cpe.vendor == OpenSourceProducts.vendor,
Cpe.product == OpenSourceProducts.product))
unique_products = unique_products.filter(
OpenSourceProducts.vendor.is_(None))
dump_query(unique_products)
# We don't do any updates for now.
created = 0
for entry in unique_products:
new_entry = OpenSourceProducts(vendor=entry.vendor,
product=entry.product)
db.session.add(new_entry)
sys.stdout.write(".")
sys.stdout.flush()
created += 1
db.session.commit()
print("")
sys.stdout.write("created(")
write_highlighted(created, Fore.GREEN, False)
sys.stdout.write(")")