Import cx_Oracle class Oracle_connect (): DEF __init__ (Self, username, password, host_ip, Port, instance_name, SQL): '' ' : param username: Database Username : param password: Database password : param host_ip: database host IP address : param port: database host port : param instance_name: database instance name : param sql: database execute SQL statements ' '' self.username = username self.password = password self.host_ip = host_ip self.port = port self.instance_name= Instance_name self.sql = SQL DEF get_Data (Self): the try : Conn = the cx_Oracle.connect ( ' {} / {} {@}: {} / {} ' .format (self.username, self.password, Self. host_ip, self.port, self.instance_name)) # connection string database cursor = conn.cursor () # using the cursor () method to get the cursor operation Result = the cursor.execute (self.sql) # execute SQL statements data = cursor. or fetchall () # remove all database data cursor.close () conn.Close () return data # Return data the except : Print ( ' \ 033 [. 1; 35m failed:! {} Database connection failure !!! \ 033 [0m ' .format (self.host_ip)) DEF get_dic (Self): the try : Conn = cx_Oracle .connect ( ' {} / {} {@}: {} / {} ' .format (self.username, self.password, self.host_ip, self.port, self.instance_name)) # connection string database cursor = conn.cursor () # using the cursor () method to get the cursor operation Result = the cursor.execute (self.sql) # execute SQL statements index = in cursor.description cursor.close () conn.Close () return index # returned data the except : Print ( ' \ 033 [. 1; 35m failed: {} database connection failure !!! \ 033 [0m! ' .format (self.host_ip)) DEF UPDATE_DATE (Self , SQL): the try : Conn = the cx_Oracle.connect ( ' {} / {} {@}: {} / {} ' .format (self.username, self.password, self.host_ip, self.port, self.instance_name )) # connection string database cursor = conn.cursor () # using the cursor () method to get the cursor operation Result = the cursor.execute (SQL) # execute SQL statements the cursor.execute ( " the commit" ) Cursor.close () conn.Close () the except : Print ( ' \ 033 [. 1; 35m failed:! {} Database connection failure !!! \ 033 [0m ' .format (self.host_ip)) DEF insert_date (Self, SQL): the try : Conn = the cx_Oracle.connect ( ' {} / {} {@}: {} / {} ' .format (self.username, self.password, self.host_ip, self.port, Self .instance_name)) # connection string database cursor = conn.cursor () # using the cursor () method to get the cursor operation the cursor.execute (SQL) # execute SQL statements the cursor.execute ( "the commit " ) cursor.close () conn.Close () the except : Print ( ' \ 033 [. 1; 35m failed:! {} database connection failure !!! \ 033 [0m ' .format (self.host_ip))