MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / run

Function run

examples/pydantic/tutorial_4.py:89–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89async def run():
90 await Tortoise.init(db_url="sqlite://:memory:", modules={"models": ["__main__"]})
91 await Tortoise.generate_schemas()
92
93 # Create objects
94 tournament = await Tournament.create(name="New Tournament")
95 await Event.create(name="Event 1", tournament=tournament)
96 await Event.create(name="Event 2", tournament=tournament)
97
98 # Serialise Tournament
99 tourpy = await Tournament_Pydantic.from_tortoise_orm(tournament)
100
101 # As serialised JSON
102 print(tourpy.model_dump_json(indent=4))
103
104
105if __name__ == "__main__":

Callers 1

tutorial_4.pyFile · 0.70

Calls 4

from_tortoise_ormMethod · 0.80
initMethod · 0.45
generate_schemasMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected