Reputation: 1
so i have tables with same purpose for each entity and they are from legacy system, thats why i cannot perform migration. For example :
So here is my view.py but i cannot do entity1_data.union(entity2_data). How can i merge these, so i can present it in 1 table?
Ps: i would try union SQL, but theres too long.
entity1_data = BlogModel.objects.using("bcdb").raw("SELECT blog.id as id, blog.name," +
"entry.title, " +
"entry.date " +
"FROM [Entity1 Blog] as blog " +
"INNER JOIN [Entity1 Entry] as entry " +
"on blog.id = entry.blog_id")
entity2_data = BlogModel.objects.using("bcdb").raw("SELECT blog.id as id, blog.name," +
"entry.title, " +
"entry.date " +
"FROM [Entity2 Blog] as blog " +
"INNER JOIN [Entity2 Entry] as entry " +
"on blog.id = entry.blog_id")
I hope i can do it dynamically using dict of tables name.
Merged table
| Blog ID | Blog Name | Entry Title | Entry Date |
| ------------------ | -------------------- | ---------------------- | --------------------- |
| [Entity 1 Blog].ID | [Entity 1 Blog].name | [Entity 1 Entry].title | [Entity 1 Entry].date |
| [Entity 2 Blog].ID | [Entity 2 Blog].name | [Entity 2 Entry].title | [Entity 2 Entry].date |
| [Entity 9 Blog].ID | [Entity 9 Blog].name | [Entity 9 Entry].title | [Entity 9 Entry].date |
Upvotes: 0
Views: 40