MySQL Forums
Forum List  »  Router & Proxy

Re: A database redirect Question
Posted by: Pete Clapham
Date: April 02, 2008 10:55AM

Aha, many thanks for the pointer. The script now works every other mysql connection.. i.e. connect to test 1 then test 2 (test 2 will fail) repeat connect to test 2 and it will succeed. Then connect to test 1 and it will attempt test 2 again. Redo and it will connect to test 1.

It clearly remembers the last connect but doesn't refresh on the next connect. Apologies again, this can't be the best way to achieve the objective, any pointers are as always much appreciated.

Existing script below:
function read_auth( auth )   
        proxy.global.dbtest=auth.default_db
end

function connect_server()

        if proxy.global.dbtest == "test1" then
                print("Connecting to database : " .. proxy.global.dbtest)
                proxy.connection.backend_ndx = 1
                print("Choosing backend port 5301");

        elseif proxy.global.dbtest == "test2" then
                print("Connecting to database : " .. proxy.global.dbtest)
                proxy.connection.backend_ndx = 2
                print("Choosing backend port 5302");

        elseif proxy.global.dbtest == "test3" then
                print("Connecting to database : " .. proxy.global.dbtest)
                proxy.connection.backend_ndx = 3
                print("Choosing backend port 5303");
        end
end



Edited 1 time(s). Last edit at 04/02/2008 06:20PM by Jan Kneschke.

Options: ReplyQuote


Subject
Views
Written By
Posted
6706
March 26, 2008 09:31AM
3460
March 27, 2008 06:07AM
3708
March 28, 2008 12:44AM
Re: A database redirect Question
3985
April 02, 2008 10:55AM
3361
April 03, 2008 06:51AM
3428
April 04, 2008 10:26AM
2736
April 07, 2008 02:45AM
3252
April 07, 2008 03:00AM
2881
December 19, 2008 02:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.