You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copyright (C) 2013 Markus Siemens <markus@m-siemens.de>
1
+
MIT License
2
2
3
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+
Copyright (c) VermiIIi0n
4
4
5
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+
Permission is hereby granted, free of charge, to any person obtaining a copy
6
+
of this software and associated documentation files (the "Software"), to deal
7
+
in the Software without restriction, including without limitation the rights
8
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+
copies of the Software, and to permit persons to whom the Software is
10
+
furnished to do so, subject to the following conditions:
6
11
7
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+
The above copyright notice and this permission notice shall be included in all
13
+
copies or substantial portions of the Software.
14
+
15
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Copy file name to clipboardExpand all lines: README.md
+66-52Lines changed: 66 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## What's This?
4
4
5
-
An asynchronous version of `TinyDB` based on `aiofiles`.
5
+
An asynchronous version of `TinyDB`.
6
6
7
7
Almost every method is asynchronous. And it's based on `TinyDB 4.7.0+`.
8
8
@@ -12,42 +12,38 @@ I will try to keep up with the latest version of `TinyDB`.
12
12
13
13
## Incompatible Changes
14
14
15
-
Major Changes:
16
-
17
15
***Asynchronous**: Say goodbye to blocking IO. **Don't forget to `await` async methods**!
18
-
***Drop support**: Only supports Python 3.8+.
19
-
20
-
Minor Changes:
21
16
22
-
***Lazy-load:** When `access_mode` is set to `'r'`, `FileNotExistsError` is not raised until the first read operation.
17
+
***Drop support**: Only supports Python 3.10+. (for 3.8+ go to this [branch](https://github.com/VermiIIi0n/async-tinydb/tree/legacy))
23
18
24
-
***`ujson`:** Using `ujson` instead of `json`. Some arguments aren't compatible with `json`
25
-
Why not `orjson`? Because `ujson` is fast enough and has more features.
19
+
***`ujson`:** Using `ujson` instead of `json`. Some arguments aren't compatible with `json`[^1]
26
20
27
21
***Storage `closed` property**: Original `TinyDB` won't raise exceptions when operating on a closed file. Now the property `closed` of `Storage` classes is required to be implemented. An `IOError` should be raised.
28
22
29
-
***`CachingMiddleWare`**: `WRITE_CACHE_SIZE` is now instance-specific.
***[Miscellaneous](#misc)**: Differences only matter in edge cases.
31
24
32
25
## New Features
33
26
34
27
***Event hooks**: You can now use event hooks to do something before or after an operation. See [Event Hooks](#event-hooks) for more details.
35
28
36
-
***Redesigned ID & Doc class**: You can [customise them](#customise-id-class) more pleasingly.
37
-
The default ID class is `IncreID`, which mimics the behaviours of the original `int` ID but requires much fewer IO operations.
38
-
The default Doc class remains almost the same.
29
+
***Redesigned ID & Doc class**: You can [replace](#replacing-id-&-document-class) and [customise them](#customise-id-class) more pleasingly.
30
+
31
+
***DB-level caching**: This significantly improves the performance of all operations. However, the responsibility of converting the data to the correct type is transferred to the Storage[^2][^disable-db-level].
32
+
33
+
***Built-in `Modifier`**: Use `Modifier` to easily [encrypt](#encryption), [compress](./docs/Modifier.md#Compression) and [extend types](./docs/Modifier.md#Conversion) of your database. Sure you can do much more than these. _(See [Modifier](./docs/Modifier.md))_
39
34
40
-
***DB level caching**: This significantly improves the performance of all operations. But it requires more memory, and the responsibility of converting the data to the correct type is transmitted to the Storage. e.g. `JSONStorage` needs to convert the keys to `str` by itself.
35
+
***Isolation Level**: Performance or ACID? It's up to you[^isolevel].
41
36
42
-
***Built-in `Modifier`**: Use `Modifier` to easily [encrypt](#encryption) and [compress](#compression) your database. Sure you can do much more than these. _(See [Modifier](./docs/Modifier.md))_
To avoid blocking codes, Async-TinyDB puts CPU-bound tasks to another thread/process (On Linux, if forking a process is possible, `ProcessPoolExecutor` will be used instead of the `ThreadPoolExecutor`).
117
+
To avoid blocking codes, Async-TinyDB puts CPU-bound tasks into another thread (Useful with interpreters without GIL)
131
118
132
119
Unfortunately, this introduces chances of data being modified when:
133
120
134
121
* Manipulating mutable objects within `Document` instances in another coroutine
135
122
* Performing updating/saving/searching operations (These operations are run in a different thread/process)
136
123
* The conditions above are satisfied in the same `Table`
137
-
* The conditions above are satisfied simultaneously
124
+
* The conditions above are satisfied simultaneously.
138
125
139
-
You can either avoid these operations or set a higher isolation level to mitigate this problem.
126
+
Avoid these operations or set a higher isolation level to mitigate this problem.
140
127
141
128
```Python
142
-
db.isolevel =1# By default isolevel is 0
129
+
db.isolevel =2
143
130
```
144
131
145
132
`isolevel`:
146
133
147
134
0. No isolation
148
-
1. Don't run operations in another thread/process, or run in a blocking way.
0 commit comments