Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Low level hooks for multi-database support in Django. As discussed in this sub-thread on reddit: The internal Django Query class has a ’connection’ attribute which can be set by the constructor. This low level hook is the secret to talking to more than one database at once, but higher level APIs have not yet been defined. Jacob Kaplan-Moss: “As a matter of fact, at least a couple high-traffic Django sites are using the new hooks.”

3 comments

  1. Wow! That's good news!

    Is it means that I can setup master-slaves MySQL cluster and all write operation will go to the master and reads will be performed from the slaves?

    Alexander Artemenko - 4th September 2008 10:48 - #

  2. @Alexander: This might not be what you're looking for, but I've always run a database proxy for operations like that. Not only can they route based on type of query (SELECT/UPDATE/INSERT), but they can keep persistent connections open so that you don't have the constant overhead of creating connections.

    That's my preferred way of dealing with connecting to replicated databases.

    Sean - 4th September 2008 15:15 - #

  3. @Sean, this is very interesting! Which database proxy do you use?

    Alexander Artemenko - 5th September 2008 12:17 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site