def _should_create_database(connection):
    # TODO: Notice when the Model classes change and return True. Worst case,
    # we can generate sqlall and hash it, though it's a bit slow (2 secs) and
    # hits the DB for no good reason. Until we find a faster way, I'm inclined
    # to keep making people explicitly saying REUSE_DB if they want to reuse
    # the DB.

    if not _can_support_reuse_db(connection):
        return True

    # Notice whether the DB exists, and create it if it doesn't:
    try:
        # Connections are cached by some backends, if other code has connected
        # to the database previously under a different database name the
        # cached connection will be used and no exception will be raised.
        # Avoiding this by closing connections and setting to null
        for connection in connections.all():
            connection.close()
        connection.connection = None
        connection.cursor()
    except Exception:  # TODO: Be more discerning but still DB agnostic.
        return True
    return not _reusing_db()
Return whether we should recreate the given DB.
dataset/ETHPy150Open django-nose/django-nose/django_nose/runner.py/_should_create_database