def get_total_row_number(): """ " " Get sum of row number in table " return integer() " """ connector = conn() db_cursor = connector.cursor() db_cursor.execute(get_sql_statement('get_row_number')) return int(db_cursor.rowcount)
def get_min_salary(): system('clear') print('\t GET MIN SALARY \t\n') connector = conn() db_cursor = connector.cursor() db_cursor.execute(get_sql_statement('min')) min_salary_data = db_cursor.fetchall() print('\nName : ', min_salary_data[0][0]) print('Salary : ', min_salary_data[0][1]) db_cursor.close() connector.close()
def get_max_salary(): system('clear') print('\t\n GET MAX SALARY \t\n') connect = conn() db_cursor = connect.cursor() db_cursor.execute(get_sql_statment('max')) data_result = db_cursor.fetchall() for data in enumerate(data_result, start=1): print(data[0], '\tName : ', data[1][0]) print('\tSalary: ', data[1][1]) print('\n') db_cursor.close() connect.close()
def delete_data(employee_name): try: connect = conn() db_cursor = connect.cursor() print("Are you sure want to delete ", employee_name, " profile ??(y/n) -> ", end='') delete_choice = str(input()) if delete_choice in ('y', 'Y'): sql_query = get_delete_data_statement(employee_name) db_cursor.execute(sql_query) connect.commit() print('OPERATION SUCCESSFULLY . . . .') else: print("Aborted To Delete ", employee_name, " Profile") db_cursor.close() connect.close() except (psycopg2.DatabaseError) as error: print(error) except (psycopg2.DataError) as error: print(error)
def open_db(self): connect = conn() return connect