Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import logging 

2from enum import Enum 

3 

4 

5class SDCDBTypes(Enum): 

6 SNOWFLAKE = "snowflake" 

7 MYSQL = "mysql" 

8 NEXUS = "nexus" 

9 POSTGRES = "postgres" 

10 ODBC = "odbc" 

11 ODBC_NETSUITE = "odbc-netsuite" 

12 

13 

14class Database(object): 

15 

16 connection = None 

17 

18 def __init__(self): 

19 logging.info("Base constructor.") 

20 

21 def connect(self, **kwargs): 

22 """ 

23 Creates database connections and cursor object (if applicable). 

24 :param kwargs: 

25 :return: Cursor object (if applicable) to self.cursor 

26 """ 

27 

28 logging.error("You should not be using the base class " "connect function.") 

29 

30 def execute_query(self, query_): 

31 """ 

32 Executes query and returns a cusir/proxy object to 

33 self.query_results if selected to do so. 

34 :param query_: A query string to execute against a database. 

35 """ 

36 

37 logging.error("You should not be using the base class " "execute_query function.") 

38 

39 def get_results(self): 

40 """ 

41 Returns results from cursor/proxy object at self.query_results. 

42 :return: A tuple or tuple-like object of results 

43 """ 

44 

45 logging.error("You should not be using the base class " "get_results function.") 

46 

47 def close_connection(self): 

48 """ 

49 Closes database connection. 

50 :return: None 

51 """ 

52 

53 logging.error("You should not be using the base class " "close_connection function.") 

54 

55 def insert_data(self, data_list_, upsert=False): 

56 """ 

57 Inserts data into database. 

58 :param data_list_: 

59 :param upsert: 

60 """ 

61 

62 logging.error("You should not be using the base class " "insert_data function.")