I have different data databases of same database schema (also in 1 database: different tables with same structure/schema) and I want use those databases in all my other apps as data backend.
For example, database name: database1
class tableA(models.Model):
a = models.CharField()
b = models.CharField()
class Meta:
db_table = 'tableA'
class tableB(models.Model):
c = models.CharField()
d = models.CharField()
class Meta:
db_table = 'tableB'
class tableC(models.Model):
c = models.CharField()
d = models.CharField()
class Meta:
db_table = 'tableC'
database name: database2
class tableA(models.Model):
a = models.CharField()
b = models.CharField()
class Meta:
db_table = 'tableA'
class tableB(models.Model):
c = models.CharField()
d = models.CharField()
class Meta:
db_table = 'tableB'
class tableC(models.Model):
c = models.CharField()
d = models.CharField()
class Meta:
db_table = 'tableC'
Here, you can see database1 and database2 is having same schema. Also in both databases, tables: tableB and tableC having same schema. In short there is seperate database created for each region with same structure instead of 1 big database for all regions. In 1 database I have around 15 tables and out of 15, 12 tables having same schema in which daily data is stored.
Can anyone please tell me how should I design this in django? Should I create 1 app with multiple model files (1 for each database) and direct it to different databases with router? How? Or create different app for each database? You can see in both cases there is a lot of code redudency as all model files having same structure.