On Jun 11, 2008, at 10:01 AM, fairwinds wrote:

>
> Hi, I have been thinking about logic for a second DSN for failover
> with some time interval to try the second source. If I am using
> asynchronous replication, time is required to allow slave to become
> master.
>
> For application logic, I don't want to tolerate a failure. Rather, I
> want to log exception and setup up a sleep and try cycle until the
> next DSN is available.
>
> I am wondering if this logic ought to be in sqlalchemy's create_engine
> to allow a second DSN and a parameter for time between tries to second
> DSN. Overall, connections to original DSN would die and exception
> would trigger trying the second source. Perhaps there are alternatives
> also. Many thanks.


its out of scope to be within create_engine itself.  create_engine  
doesn't even make any connections to the database.

an appropriate method here would be to create a function as follows:

from sqlalchemy import create_engine as _create_engine

def create_engine(url1, url2):
        e = _create_engine(url1)
        try:
                c = e.connect()
                c.close()
                return e
        except:
                # log error
                # ....

                return _create_engine(url2)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to