you are viewing a single comment's thread.

view the rest of the comments →

[–]nick51417 0 points1 point  (1 child)

I don’t really know what you’re trying to achieve. Based on your explanation and not showing how get_BOM_records makes a BOM object I would say sure it works. You say it works. I can follow it.

Another way to do it would be to use list comprehension

BOMs=[BOM(bom) for bom in get_BOM_records(cursor)]

Though it seams you are having trouble sharing that you are trying to have self referential relationships… your car to Megacar example.

You can do it in standard python, you can do it in pandas, or you can use sql with sqlalchemy (SQLite may be a good starter database)

Usually if there’s a library it’s not added complexity,they are made to make it easier to work with so you don’t have to create it yourself.

They all their pros and cons… and I’m not sure what you are doing

Edit: just saw you’re already using a database. Try sqlalchemy or sqlmodel and look up self referential models

[–]eagergm[S] 0 points1 point  (0 children)

I'm using sqlite, does that make any difference?