code: def export_datasources(print_stdout, datasource_file,
                         back_references, include_defaults):
      
      data = dict_import_export.export_to_dict(
          session=db.session,
          recursive=True,
          back_references=back_references,
          include_defaults=include_defaults)
      if print_stdout or not datasource_file:
          yaml.safe_dump(data, stdout, default_flow_style=False)
      if datasource_file:
          logging.info('Exporting datasources to %s', datasource_file)
          with open(datasource_file, 'w') as data_stream:
              yaml.safe_dump(data, data_stream, default_flow_style=False)
docs: Export datasources to YAML