For sqlite, percent-substitute %(basedir)s and use a full
        path to the basedir.  If using a memory database, force the
        pool size to be 1.

def special_case_sqlite(self, u, kwargs):
        """For sqlite, percent-substitute %(basedir)s and use a full
        path to the basedir.  If using a memory database, force the
        pool size to be 1."""
        max_conns = 1

        # when given a database path, stick the basedir in there
        if u.database:

            # Use NullPool instead of the sqlalchemy-0.6.8-default
            # SingletonThreadPool for sqlite to suppress the error in
            # http://groups.google.com/group/sqlalchemy/msg/f8482e4721a89589,
            # which also explains that NullPool is the new default in
            # sqlalchemy 0.7 for non-memory SQLite databases.
            kwargs.setdefault('poolclass', NullPool)

            u.database = u.database % dict(basedir=kwargs['basedir'])
            if not os.path.isabs(u.database[0]):
                u.database = os.path.join(kwargs['basedir'], u.database)

        else:
            # For in-memory database SQLAlchemy will use SingletonThreadPool
            # and we will run connection creation and all queries in the single
            # thread.
            # However connection destruction will be run from the main
            # thread, which is safe in our case, but not safe in general,
            # so SQLite will emit warning about it.
            # Silence that warning.
            kwargs.setdefault('connect_args', {})['check_same_thread'] = False

        # ignore serializing access to the db
        if 'serialize_access' in u.query:
            u.query.pop('serialize_access')

        return u, kwargs, max_conns