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

1#!/usr/bin/env python3 

2 

3import logging 

4 

5import pyodbc 

6 

7from sdc_etl_libs.database_helpers.ODBCDatabase import ODBCDatabase 

8 

9 

10class ODBCNetsuite(ODBCDatabase): 

11 # Set logger up 

12 logging.basicConfig(format='%(levelname)s: %(asctime)s: ' '%(funcName)s: %(message)s') 

13 logger = logging.getLogger(__name__) 

14 logger.setLevel(logging.INFO) 

15 

16 def __init__(self, schema_, endpoint_schema_, **kwargs): 

17 super(ODBCNetsuite, self).__init__(schema_, endpoint_schema_, **kwargs) 

18 

19 self.account = self.credentials.get("account") 

20 self.driver = "{CData ODBC Driver for NetSuite}" 

21 

22 logging.info("ODBC Netsuite constructor.") 

23 

24 def connect(self, airflow_=False): 

25 """ 

26 Connects to ODBC Netsuite Database. 

27 :airflow_ Boolean to indicate running from airflow or not 

28 :return: Nothing 

29 """ 

30 

31 self.airflow = airflow_ 

32 

33 logging.info("%s", "Connecting to ODBC Server via Driver Connection String") 

34 

35 self.connection = pyodbc.connect( 

36 """DRIVER={driver};Account Id={account}; Password ={password}; User ={user};version=2019_1""".format( 

37 driver=self.driver, account=self.account, password=self.password, user=self.user)) 

38 

39 try: 

40 self.cursor = self.connection.cursor() 

41 logging.info("Connected to ODBC Netsuite.") 

42 

43 except Exception as e: 

44 logging.exception("Error connecting to ODBC.") 

45 raise Exception