I have something like this:
class A ():
[...]
class B ():
def __init__(self):
self.fubar = A()
And I would like to store B into a database via SQLAlchemy. I think that I need to define both A and B as two different tables — mapping all the other properties of A and B appropriately. Then, I need to map A to B as a property but I am not sure how to do that.
Is my thinking good or did I miss something? Any idea what functions call I am missing — or what page of the documentation covers it?
Thanks
You should indeed define two database entities,
AandB, and a 1:1 or 1:n relationship between those two:For a real-world example, read the ORM tutorial, where your class
Ais namedUserandBAddress.