I’m not very good in Django or Mysql so please be tolerant,
I have this table in my DB named table_bdc
(Simplified version)
I would like to iterate through the DB to create a list of list with a query depending on the column’s name last digit (_1 or _2 or _3 and so on).
Something like :
final_list = []
for i in range(2)
result = models_bdc.objects.raw("SELECT * FROM table_bdc WHERE id='1' AND column name ends with RLIKE %s",["_"+(i+1)])
final_list.append(result)
For example with the first line (id 1), the expected result would be :
final_list = [[3,4],[6,7]]
I already searched the forum to learn and get to this point but the rest is still too complex for me yet …
Can someone please show me how to do this ?
PS: The DB cannot be refactored or changed I have to deal with it this way.
Thanks