-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.3.24.dev11 | ||
0.3.24.dev12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from sqlalchemy import insert | ||
|
||
from CveXplore.core.database_models.models import Cpe, Info | ||
from CveXplore.database.connection.sqlbase.connection import Session | ||
from CveXplore.database.connection.sqlbase.sql_client_base import SQLClientBase | ||
|
||
|
||
class SQLClient(SQLClientBase): | ||
def __init__(self, collection_name: str): | ||
super().__init__(logger_name=__name__) | ||
self.session = Session | ||
self.collection_name = collection_name | ||
|
||
self.model_mapping = {"info": Info, "cpe": Cpe} | ||
|
||
def bulk_write(self, write_entries: list, ordered: bool = False): | ||
with self.session() as session: | ||
session.execute( | ||
insert(self.model_mapping[self.collection_name]), write_entries | ||
) | ||
session.commit() | ||
|
||
def insert_many(self, write_entries: list, ordered: bool = False): | ||
with self.session() as session: | ||
session.execute( | ||
insert(self.model_mapping[self.collection_name]), write_entries | ||
) | ||
session.commit() | ||
|
||
def delete_one(self, *args, **kwargs): | ||
pass | ||
|
||
def drop(self, *args, **kwargs): | ||
pass | ||
|
||
def update_one(self, *args, **kwargs): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import logging | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class SQLClientBase(ABC): | ||
def __init__(self, logger_name: str): | ||
self.logger = logging.getLogger(logger_name) | ||
|
||
def __repr__(self): | ||
return f"<<{self.__class__.__name__}>>" | ||
|
||
@abstractmethod | ||
def bulk_write(self, *args, **kwargs): | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def insert_many(self, *args, **kwargs): | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def delete_one(self, *args, **kwargs): | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def drop(self, *args, **kwargs): | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def update_one(self, *args, **kwargs): | ||
raise NotImplementedError |