code: def _format_url(url, driver, ident):
      """given a sqlite url + desired driver + ident, make a canonical
      URL out of it
  
      """
      url = sa_url.make_url(url)
  
      if driver is None:
          driver = url.get_driver_name()
  
      filename = url.database
  
      needs_enc = driver == "pysqlcipher"
      name_token = None
  
      if filename and filename != ":memory:":
          assert "test_schema" not in filename
          tokens = re.split(r"[_\.]", filename)
  
          new_filename = f"{driver}"
  
          for token in tokens:
              if token in _drivernames:
                  if driver is None:
                      driver = token
                  continue
              elif token in ("db", "enc"):
                  continue
              elif name_token is None:
                  name_token = token.strip("_")
  
          assert (
              name_token
          ), f"sqlite filename has no name token: {url.database}"
  
          new_filename = f"{name_token}_{driver}"
          if ident:
              new_filename += f"_{ident}"
          new_filename += ".db"
          if needs_enc:
              new_filename += ".enc"
          url = url.set(database=new_filename)
  
      if needs_enc:
          url = url.set(password="test")
  
      url = url.set(drivername="sqlite+%s" % (driver,))
  
      return url
  
imports: import os
  import re
  from ...None import exc
  from ...engine import url
  from ...testing.provision import create_db
  from ...testing.provision import drop_db
  from ...testing.provision import follower_url_from_main
  from ...testing.provision import generate_driver_url
  from ...testing.provision import log
  from ...testing.provision import post_configure_engine
  from ...testing.provision import run_reap_dbs
  from ...testing.provision import stop_test_class_outside_fixtures
  from ...testing.provision import temp_table_keyword_args
  from ...testing.provision import upsert
label_desc: Use image node_id 1 for calling a global function with example usage: _format_url(url, driver, ident) and returns: url