code: def test_db_engine_spec(
      console: Console,
      sqlalchemy_uri: str,
  ) -> type[BaseEngineSpec] | None:
      """
      Test the DB engine spec, if available.
      """
      spec: type[BaseEngineSpec] | None = None
      for spec in load_engine_specs():
          try:
              supported = spec.supports_url(
                  make_url_safe(sqlalchemy_uri)
              )
          except NoSuchModuleError:
              console.print(
                  "[red]No SQLAlchemy dialect found for the URI!"
              )
              console.print("[bold]Exiting...")
              sys.exit(1)
  
          if supported:
              if spec.__module__.startswith("superset.db_engine_specs"):
                  console.print(
                      f":thumbs_up: [green]Found DB engine spec: [bold]{spec.engine_name}"
                  )
              else:
                  console.print(
                      ":warning: [yellow]Found 3rd party DB engine spec: "
                      f"[bold]{spec.engine_name} ({spec.__module__})"
                  )
              break
      else:
          console.print(
              ":thumbs_down: [red]No DB engine spec found for the SQLAlchemy URI. The "
              "database can still be used with Superset, but some functionality may be "
              "limited."
          )
  
      if spec is None:
          return None
  
      info = diagnose(spec)
  
      console.print("About the database:")
      console.print(
          "  - Method used to apply LIMIT to queries:",
          info["limit_method"],
      )
      for k, v in LIMIT_METHODS.items():
          console.print(f"    - {k}: {v}")
      for key, feature in DATABASE_DETAILS.items():
          console.print(f"  - {feature}:", info[key])
  
      console.print("[bold]Checking for basic features...")
      console.print("Supported time grains:")
      for k, v in info["time_grains"].items():
          score = " (+1)" if v else ""
          console.print(f"  - {k}: {v}{score}")
      for k, v in BASIC_FEATURES.items():
          score = " (+10)" if info[k] else ""
          console.print(f"{v}: {info[k]}{score}")
  
      console.print("[bold]Checking for nice-to-have features...")
      for k, v in NICE_TO_HAVE_FEATURES.items():
          score = " (+10)" if info[k] else ""
          console.print(f"{v}: {info[k]}{score}")
  
      console.print("[bold]Checking for advanced features...")
      for k, v in ADVANCED_FEATURES.items():
          score = " (+10)" if info[k] else ""
          console.print(f"{v}: {info[k]}{score}")
  
      # pylint: disable=consider-using-f-string
      console.print(
          "[bold]Overall score: {score}/{max_score}".format(**info)
      )
  
      return spec
  
imports: from __future__ import annotations
  import sys
  from collections import defaultdict
  from datetime import datetime
  from typing import Any, Callable
  import click
  import yaml
  from rich.console import Console
  from sqlalchemy import Column, create_engine, DateTime, ForeignKey, insert, Integer, MetaData, select, String, Table
  from sqlalchemy.engine import Engine
  from sqlalchemy.exc import NoSuchModuleError
  from superset.databases.utils import make_url_safe
  from superset.db_engine_specs import load_engine_specs
  from superset.db_engine_specs.base import BaseEngineSpec
  from superset.db_engine_specs.lib import ADVANCED_FEATURES, BASIC_FEATURES, DATABASE_DETAILS, diagnose, LIMIT_METHODS, NICE_TO_HAVE_FEATURES
label_desc: Use image node_id 4 for calling a global function with example usage: test_db_engine_spec(console, sqlalchemy_uri) and returns: spec, None