Hey guys i have a problem. There is an application that i built using django and it runs on postgresql. The application works perfectly but until recently , i was asked to push particular table data in the models of the django application to a remote oracle database. For example i have a model that looks like this:
class SimRegistrationForm(models.Model):
mobile_number = models.IntegerField('Mobile Number',max_length=10, null=False, blank=False)
alternative_number = models.IntegerField('Alternative Number',max_length=10, blank=True, null=True)
date = models.DateField('Date', blank=False, null=False)
honorifics = models.CharField('Honorific', max_length=10, choices=HONORIFIC, blank=False, null=False)
first_name = models.CharField('First Name',max_length=30, blank=False, null=False)
middle_name = models.CharField('Middle Name',max_length=30, blank=True, null=True)
last_name = models.CharField('Last Name',max_length=30, blank=False, null=False)
dob = models.DateField('Date of Birth', blank=False, null=False)
nationality = models.CharField(max_length=30, null=False, blank=False)
I have asked this question before on this forum but have not had as much help with very little response. How can i be able to achieve this ? I know django supports multiple database connections basing on what i have read here
https://docs.djangoproject.com/en/dev/topics/db/multi-db/
I would like such that it pushes some of the table data to the remote oracle database in realtime and data should also remain on the postgres database too. How can i achieve this?
Seems like you want to replicate the data from postgresql to oracle for some particular model.
MultiDB is not conceived for replication, but with a recent version of Django you can be able to pull this stunt.
Configure Django with two databases, the postgresql as default and the oracle as a second database. Lets say you called the second database database “orcl”:
super()“save” method and alsosuper(YourModel, self).save(using='orcl')Should be something like this (untested):
[update]
I think it is possible. Keeping the same pk on both databases will make your life easier:
Let me know if this works. You have to either 1) define the OtherModel and create the corresponding table in the remote database or 2) create the remote table and use
manage.py inspectdbto create the model.