MCPcopy
hub / github.com/ormar-orm/ormar / run_query

Function run_query

docs_src/queries/docs005.py:33–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31
32@create_drop_database(base_config=ormar_base_config)
33async def run_query():
34 await Book.objects.create(
35 title="Tom Sawyer", author="Twain, Mark", genre="Adventure"
36 )
37 await Book.objects.create(
38 title="War and Peace in Space", author="Tolstoy, Leo", genre="Fantasy"
39 )
40 await Book.objects.create(
41 title="Anna Karenina", author="Tolstoy, Leo", genre="Fiction"
42 )
43
44 # delete accepts kwargs that will be used in filter
45 # acting in same way as queryset.filter(**kwargs).delete()
46 await Book.objects.delete(genre="Fantasy") # delete all fantasy books
47 all_books = await Book.objects.all()
48 assert len(all_books) == 2
49
50
51asyncio.run(run_query())

Callers 1

docs005.pyFile · 0.70

Calls 3

createMethod · 0.45
deleteMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected