Hi Luciano,
as long as you can create regular expression to match and replace your queries, it should be possible.
Therefore, the complex part here is to be able to create regex that match all the queries.
For examples:
a) if you have queries like:
"INSERT INTO cache_table1 VALUES"
you could create a query rules like:
INSERT INTO mysql_query_rules (active,match_pattern,replace_pattern,apply) VALUES (1,'^INSERT INTO cache_table1 VALUES', ''INSERT INTO otherdb.cache_table1 VALUES',1);
b) if you have queries like:
"SELECT ... FROM cache_table2 WHERE ..."
you could create a query rules like:
INSERT
INTO mysql_query_rules (active,match_pattern,replace_pattern,apply)
VALUES (1,'^SELECT (.*) FROM cache_table2 WHERE', ''SELECT \1 FROM otherdb.cache_table2 WHERE',1);
Etc, etc.