Re: Database Routing

2017-05-18 Thread Derek
You'll need to post actual code and error stack traces if you want people to help. On Wednesday, 17 May 2017 15:08:55 UTC+2, Joe wrote: > > I am in the process of setting up a django server. I am trying to connect > our 4 legacy DBs to her. I have created a separate app for each DB, added > the

Database Routing

2017-05-17 Thread Joe
I am in the process of setting up a django server. I am trying to connect our 4 legacy DBs to her. I have created a separate app for each DB, added the app_label to the meta of the model and wrote a read only router for each db. This was working fine until i got to the last one. The routing is

Re: Dynamic database routing in Django

2014-03-12 Thread Xavier Ordoquy
Hi Philip, I'm not sure your sharding will be possible in the way you describe it. There will be cases for which selecting the database will not be possible. For example, Customer.objects.get(name=) won't be able which DB you'll need to hit to get the result. Same goes for a new Customer. H

Dynamic database routing in Django

2014-03-12 Thread Philip Goh
Hello list, In my database, I have a `Customer` table defined in my database that all other tables are foreign keyed on. class Customer(models.Model): ... class TableA(models.Model): Customer = models.ForeignKey(Customer) ... class TableB(models.Model):

Re: Multiple Database Routing Based on Site

2011-09-02 Thread Mo Mughrabi
What I did is create an attribute in my models and called it model.py class Data(models.Model): # connection_name is my database name which points to the name from settings.py connection_name = "gis" name = models.CharField(max_length=50) area = models.IntegerField() and created a

Re: Multiple Database Routing Based on Site

2011-09-02 Thread Kevin
The only solution I can directly think of, since the SITE_ID is in settings.py would be to use some python logic to determine the database for that site. eg. if SITE_ID == 1: ... Database settings for site 1 here ... Use an if-then like this in your settings.py. Now if what your going after

Multiple Database Routing Based on Site

2011-09-01 Thread Terribyte
I had a kind of crazy idea and I wanted to bounce it off of some people with a lot more django experience than I. Here's my scenario... I would like 1 code base, this code base services potentially hundreds of businesses, each of which I want to have a copy of the same schema but with data only r

Re: Multi-db: is database routing per request possible?

2010-06-16 Thread johan de taeye
Russ, Your gut feeling confirms my suspicion. Changing the lines to the following fixes my problem: db = model_instance._state.db if db is None: db = router.db_for_write(model_instance.__class__, instance=model_instance) qs = self.rel.to._default_manager.using(

Re: Multi-db: is database routing per request possible?

2010-06-15 Thread Russell Keith-Magee
On Tue, Jun 15, 2010 at 9:11 PM, johan de taeye wrote: > >> You can't do this with a router; as you've noted, the router doesn't >> have any information about the request in which it is being used. >> >> However, you could do it by manually requesting your database >> connection whenever you use t

Re: Multi-db: is database routing per request possible?

2010-06-15 Thread johan de taeye
> You can't do this with a router; as you've noted, the router doesn't > have any information about the request in which it is being used. > > However, you could do it by manually requesting your database > connection whenever you use the database. For example: > > Author.objects.using('otherdb').

Re: Multi-db: is database routing per request possible?

2010-06-15 Thread Russell Keith-Magee
On Tue, Jun 15, 2010 at 7:12 PM, johan de taeye wrote: > Hello, > > In my application a number of databases are configured with identical > schemas. > From a dropdown box on the screen, the user selects the database he/ > she wants to work with.  The selected database is stored on the > cookie. >

Re: Multi-db: is database routing per request possible?

2010-06-15 Thread Alexander Jeliuc
I didn't work with multidb but I think it is possible anyway... try it using additional middleware... for example.. change dynamically db settings... etc On Tue, Jun 15, 2010 at 2:12 PM, johan de taeye wrote: > Hello, > > In my application a number of databases are configured with identical > sch

Multi-db: is database routing per request possible?

2010-06-15 Thread johan de taeye
Hello, In my application a number of databases are configured with identical schemas. >From a dropdown box on the screen, the user selects the database he/ she wants to work with. The selected database is stored on the cookie. An object with the same primary key can be created in each schema by t