I'm new to Pydantic and trying to understand how/if I can create a new class instance. I've read through the Pydantic documentation and can't find an example doing anything similar.
My python code (prior to Pydantic) looks like:
class Person:
def __init__(self, id):
db_result = get_db_content(id) #lookup id in a database and return a result
self.name = db_result['name']
self.birth_year = db_result['birth_year']
p1 = Person(1234)
print(p1.name)
What would the corresponding code in Pydantic look like if I want to create a Person instance
based on an id? Also, is it possible with Pydantic to have multiple constructors for the same
class. For example:
p1 = Person(1234)
p2 = Person("Jane Doe")