code: def database(connection_string, db_class=SimplDB):
      
      if not hasattr(database, "singletons"):
          database.singletons = {}
      if connection_string not in database.singletons:
          instance = db_class(connection_string)
          database.singletons[connection_string] = instance
      return database.singletons[connection_string]
docs: Return database singleton instance.
  
      This function will always return the same database instance for the same
      connection_string. It stores instances in a dict saved as an attribute of
      this function.