I would like to change which database Mysql2 :: Client uses (for example, the same way as entering "use X" in the mysql command line) without having to establish a new connection to the database server.
Is it possible? How?
Use select_db
select_db
db = Mysql2::Client.new db.select_db('test')
You can use the method queryto switch databases:
query
db = Mysql2::Client.new db.query('use test') # You're now talking to the test database db.query('use something_else') # You're now talking to the something_else database