MCPcopy
hub / github.com/tortoise/tortoise-orm / run

Function run

examples/global_table_name_generator.py:39–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37
38
39async def run():
40 # Initialize with snake_case table name generator
41 await Tortoise.init(
42 db_url="sqlite://:memory:",
43 modules={"models": ["__main__"]},
44 table_name_generator=snake_case_table_names,
45 )
46 await Tortoise.generate_schemas()
47
48 # UserProfile uses generated name, BlogPost uses explicit table name
49 print(f"UserProfile table name: {UserProfile._meta.db_table}") # >>> user_profile
50 print(f"BlogPost table name: {BlogPost._meta.db_table}") # >>> custom_blog_posts
51
52 await Tortoise.close_connections()
53
54
55if __name__ == "__main__":

Callers 1

Calls 3

initMethod · 0.45
generate_schemasMethod · 0.45
close_connectionsMethod · 0.45

Tested by

no test coverage detected