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

Function run

examples/postgres.py:17–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16
17async def run():
18 await Tortoise.init(
19 {
20 "connections": {
21 "default": {
22 "engine": "tortoise.backends.asyncpg",
23 "credentials": {
24 "host": "localhost",
25 "port": "5432",
26 "user": "tortoise",
27 "password": "qwerty123",
28 "database": "test",
29 },
30 }
31 },
32 "apps": {"models": {"models": ["__main__"], "default_connection": "default"}},
33 },
34 _create_db=True,
35 )
36 await Tortoise.generate_schemas()
37
38 report_data = {"foo": "bar"}
39 print(await Report.create(content=report_data))
40 print(await Report.filter(content=report_data).first())
41 await Tortoise._drop_databases()
42
43
44if __name__ == "__main__":

Callers 1

postgres.pyFile · 0.70

Calls 6

_drop_databasesMethod · 0.80
initMethod · 0.45
generate_schemasMethod · 0.45
createMethod · 0.45
firstMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected