docstr: Updates or creates a database
docstr_tok: ["Updates","or","creates","a","database"]
code: def put(self, database_name):
      """Updates or creates a database"""
      if "database" not in request.json:
          abort(
              HTTPStatus.BAD_REQUEST,
              'Must provide "database" parameter in POST body',
          )
  
      session = SessionController()
      parameters = {}
      database = request.json["database"]
      if "parameters" in database:
          parameters = database["parameters"]
      if not session.database_controller.exists(database_name):
          # Create.
          if "engine" not in database:
              abort(
                  HTTPStatus.BAD_REQUEST,
                  'Missing "engine" field for new database. If you want to create a project instead, use the POST /api/projects endpoint.',
              )
          new_integration_id = session.integration_controller.add(
              database_name, database["engine"], parameters
          )
          new_integration = session.database_controller.get_integration(
              new_integration_id
          )
          return new_integration, HTTPStatus.CREATED
  
      session.integration_controller.modify(database_name, parameters)
      return session.integration_controller.get(database_name)
  
imports: from http import HTTPStatus
  from sqlalchemy.exc import NoResultFound
  from typing import Dict
  from flask import request
  from flask_restx import Resource, abort
  from mindsdb.api.http.namespaces.configs.databases import ns_conf
  from mindsdb.api.mysql.mysql_proxy.classes.fake_mysql_proxy import FakeMysqlProxy
  from mindsdb.api.executor.controllers.session_controller import SessionController
  from mindsdb.api.executor.datahub.classes.tables_row import TablesRow
  from mindsdb.api.executor.data_types.response_type import RESPONSE_TYPE
  from mindsdb_sql import parse_sql, ParsingException
  from mindsdb_sql.parser.ast import CreateTable, DropTables
label_desc: Use image node_id 2 for calling the DatabaseResource obj's underlying member method code with example usage: obj.put(database_name) and returns: session, new_integration,  HTTPStatus