# Import libraries
from configparser import ConfigParser
from pathlib import Path

def get_project_root() -> Path:
  """Returns project root folder."""
  return Path(__file__).parents[1]

def config(config_db, section_to_parse):
  section = section_to_parse 
  config_file_path = config_db
  if(len(config_file_path) > 0 and len(section) > 0):
    # Create an instance of ConfigParser class
    config_parser = ConfigParser()
    # Read the configuration file
    config_parser.read(config_file_path)
    # If the configuration file contains the provided section name
    if(config_parser.has_section(section)):
      # Read the options of the section
      config_params = config_parser.items(section)
      # Convert the list object to a python dictionary object
      # Define an empty dictionary
      db_conn_dict = {}
      # Loop in the list
      for config_param in config_params:
        # Get options key and value
        key = config_param[0]
        value = config_param[1]
        # Add the key value pair in the dictionary object
        db_conn_dict[key] = value
      # Get connection object use above dictionary object
      return db_conn_dict

def load_sql(config_db):
  section = 'create_tables'
  config_file_path = config_db
  if(len(config_file_path) > 0 and len(section) > 0):
    # Create an instance of ConfigParser class
    config_parser = ConfigParser()
    # Read the configuration file
    config_parser.read(config_file_path)
    # If the configuration file contains the provided section name
    if(config_parser.has_section(section)):
      # Read the options of the section
      config_params = config_parser.items(section)
      # Convert the list object to a python dictionary object
      # Define an empty dictionary
      db_conn_dict = {}
      # Loop in the list
      for config_param in config_params:
        # Get options key and value
        key = config_param[0]
        value = config_param[1]
        # Add the key value pair in the dictionary object
        db_conn_dict[key] = value
      # Get connection object use above dictionary object
      return db_conn_dict      
# Import libraries
from configparser import ConfigParser
from pathlib import Path

def get_project_root() -> Path:
  """Returns project root folder."""
  return Path(__file__).parents[1]

def config(config_db, section_to_parse):
  section = section_to_parse 
  config_file_path = config_db
  if(len(config_file_path) > 0 and len(section) > 0):
    # Create an instance of ConfigParser class
    config_parser = ConfigParser()
    # Read the configuration file
    config_parser.read(config_file_path)
    # If the configuration file contains the provided section name
    if(config_parser.has_section(section)):
      # Read the options of the section
      config_params = config_parser.items(section)
      # Convert the list object to a python dictionary object
      # Define an empty dictionary
      db_conn_dict = {}
      # Loop in the list
      for config_param in config_params:
        # Get options key and value
        key = config_param[0]
        value = config_param[1]
        # Add the key value pair in the dictionary object
        db_conn_dict[key] = value
      # Get connection object use above dictionary object
      return db_conn_dict

def load_sql(config_db):
  section = 'create_tables'
  config_file_path = config_db
  if(len(config_file_path) > 0 and len(section) > 0):
    # Create an instance of ConfigParser class
    config_parser = ConfigParser()
    # Read the configuration file
    config_parser.read(config_file_path)
    # If the configuration file contains the provided section name
    if(config_parser.has_section(section)):
      # Read the options of the section
      config_params = config_parser.items(section)
      # Convert the list object to a python dictionary object
      # Define an empty dictionary
      db_conn_dict = {}
      # Loop in the list
      for config_param in config_params:
        # Get options key and value
        key = config_param[0]
        value = config_param[1]
        # Add the key value pair in the dictionary object
        db_conn_dict[key] = value
      # Get connection object use above dictionary object
      return db_conn_dict      
# Import libraries Returns project root folder. # Create an instance of ConfigParser class # Read the configuration file # If the configuration file contains the provided section name # Read the options of the section # Convert the list object to a python dictionary object # Define an empty dictionary # Loop in the list # Get options key and value # Add the key value pair in the dictionary object # Get connection object use above dictionary object # Create an instance of ConfigParser class # Read the configuration file # If the configuration file contains the provided section name # Read the options of the section # Convert the list object to a python dictionary object # Define an empty dictionary # Loop in the list # Get options key and value # Add the key value pair in the dictionary object # Get connection object use above dictionary object