Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Database helper for Oracle
"""
from etlhelper.db_helpers.db_helper import DbHelper
class OracleDbHelper(DbHelper):
"""
Oracle DB helper class
"""
def __init__(self):
super().__init__()
try:
import cx_Oracle
self.sql_exceptions = (cx_Oracle.DatabaseError)
self._connect_func = cx_Oracle.connect
self.connect_exceptions = (cx_Oracle.DatabaseError)
self.required_params = {'host', 'port', 'dbname', 'user'}
except ImportError:
print("The cxOracle drivers were not found. See setup guide for more information.")
def get_connection_string(self, db_params, password_variable):
"""
"""
Database helper for Postgres
"""
from etlhelper.db_helpers.db_helper import DbHelper
class PostgresDbHelper(DbHelper):
"""
Postgres db helper class
"""
def __init__(self):
super().__init__()
try:
import psycopg2
self.sql_exceptions = (psycopg2.ProgrammingError)
self._connect_func = psycopg2.connect
self.connect_exceptions = (psycopg2.OperationalError)
self.required_params = {'host', 'port', 'dbname', 'user'}
except ImportError:
print("The PostgreSQL python libraries could not be found.\n"
"Run: python -m pip install psycopg2-binary")
def get_connection_string(self, db_params, password_variable):
"""
Database helper for mssql
"""
from etlhelper.db_helpers.db_helper import DbHelper
class MSSQLDbHelper(DbHelper):
"""
MS Sql server helper class
"""
def __init__(self):
super().__init__()
try:
import pyodbc
self.sql_exceptions = (pyodbc.DatabaseError)
self._connect_func = pyodbc.connect
self.connect_exceptions = (pyodbc.DatabaseError, pyodbc.InterfaceError)
self.required_params = {'host', 'port', 'dbname', 'user', 'odbc_driver'}
except ImportError:
print("The pyodc Python package could not be found.\n"
"Run: python -m pip install pyodbc")
def get_connection_string(self, db_params, password_variable):