Tutorial :What is a way to handle database connection failure in Django 1.2?


What is a way to handle database unavailability and redirect queries from unavailable slave to another one in Django 1.2?

Btw, i found out, that it was discussed: http://code.djangoproject.com/wiki/MultipleDatabaseSupport#Requirements (see "Transparently handling database failure")

UPD> I use PostgreSQL backend (probably will use pg pool or some other potgres cluster) under linux


If you are using a PostgreSQL backend and are on a Linux/BSD etc. system, consider using pgpool: http://www.pgpool.net/ This utility handles the connections to the DB server for you, so you only connect to pgpool. No need for you to implement any more logic. Just connect to pgpool, not to PostgreSQL itself.


Unfortunately, at the moment there's no way to use the DATABASE_ROUTERS feature in order to handle an unavailable database, you'll have to use an external tool as others have suggested.


There's also a proxy for MySQL, MySQL Proxy. You would connect to the proxy, and that proxy would know how to handle failover. In the case of MySQL Proxy, it is designed for failover, so I expect it to be both stable and knowing how to handle failures:)

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »