add large binary field, tests and docs

This commit is contained in:
collerek
2021-04-28 17:04:29 +02:00
parent 638af9ad4c
commit 11ed5fd322
13 changed files with 148 additions and 14 deletions

View File

@ -451,6 +451,16 @@ async def aggregations():
# to read more about aggregated functions
# visit: https://collerek.github.io/ormar/queries/aggregations/
async def with_connect(function):
# note that for any other backend than sqlite you actually need to
# connect to the database to perform db operations
async with database:
await function()
# note that if you use framework like `fastapi` you shouldn't connect
# in your endpoints but have a global connection pool
# check https://collerek.github.io/ormar/fastapi/ and section with db connection
# gather and execute all functions
# note - normally import should be at the beginning of the file
@ -462,7 +472,7 @@ for func in [create, read, update, delete, joins,
filter_and_sort, subset_of_columns,
pagination, aggregations]:
print(f"Executing: {func.__name__}")
asyncio.run(func())
asyncio.run(with_connect(func))
# drop the database tables
metadata.drop_all(engine)
@ -521,6 +531,7 @@ Available Model Fields (with required args - optional ones in docs):
* `BigInteger()`
* `Decimal(scale, precision)`
* `UUID()`
* `LargeBinary(max_length)`
* `EnumField` - by passing `choices` to any other Field type
* `EncryptedString` - by passing `encrypt_secret` and `encrypt_backend`
* `ForeignKey(to)`