def _swap_database(self, query):
database = _query_db(query)<EOL>if database == self.database:<EOL><INDENT>return query<EOL><DEDENT>if self._subclassed(peewee.PostgresqlDatabase, database,<EOL>self.database):<EOL><INDENT>can_swap = True<EOL><DEDENT>elif self._subclassed(peewee.MySQLDatabase, database,<EOL>self.database):<EOL><INDENT>can_swap = True<EOL><DEDENT>else:<EOL><INDENT>can_swap = False<EOL><DEDENT>if can_swap:<EOL><INDENT>query = query.clone()<EOL>query._database = self.database<EOL>return query<EOL><DEDENT>assert False, (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (database, self.database)<EOL>)<EOL>return None<EOL>
Swap database for query if swappable. Return **new query**
        with swapped database.

        This is experimental feature which allows us to have multiple
        managers configured against different databases for single model
        definition.

        The essential limitation though is that database backend have
        to be **the same type** for model and manager!