code: def import_datasources(path, sync, recursive):
      
      sync_array = sync.split(',')
      p = Path(path)
      files = []
      if p.is_file():
          files.append(p)
      elif p.exists() and not recursive:
          files.extend(p.glob('*.yaml'))
          files.extend(p.glob('*.yml'))
      elif p.exists() and recursive:
          files.extend(p.rglob('*.yaml'))
          files.extend(p.rglob('*.yml'))
      for f in files:
          logging.info('Importing datasources from file %s', f)
          try:
              with f.open() as data_stream:
                  dict_import_export.import_from_dict(
                      db.session,
                      yaml.safe_load(data_stream),
                      sync=sync_array)
          except Exception as e:
              logging.error('Error when importing datasources from file %s', f)
              logging.error(e)
docs: Import datasources from YAML