Python collections that are backended by sqlite3 DB and are compatible with the built-in collections
Project description
sqlitecollections
Python collections that are backended by sqlite3 DB and are compatible with the built-in collections
Installation
$ pip install sqlitecollections
Development
To run tests, type checking and linting locally, we use tox
.
It will run pytest
, mypy
and black
on python 3.6, 3.7, 3.8 and 3.9.
Install them via the following commands:
$ git clone git@github.com:osoken/sqlitecollections.git
$ cd sqlitecollections
$ python -m venv .venv
$ source ./.venv/bin/activate
$ pip install -e .[dev]
then, run tests:
$ tox
Compatibility policy
We aim to implement containers that are as compatible as possible with the built-in containers, but we have a few implementations that intentionally behave differently.
- Normal behavior will be compatible, but in case of errors it may be different.
- The constructor arguments are not compatible, as they require arguments specific to this package's container, such as sqlite3 DB file paths and serialization methods.
Dict
's item order is guaranteed to be insertion order not only for python 3.7 and upper but for all versions.Dict.fromkeys
class method is not provided.- Any member in the container cannot be mutated directly. If you want to mutate any member, mutate it via temporary variable then write it back.
from sqlitecollections import Dict
x = Dict(data={"a": []}) # create {"a": []}
x["a"].append("b") # try to mutate the empty list
print(x["a"]) # not ["b"] but []
temp = x["a"] # temporarily substitute the list to a variable
temp.append("b") # mutate the temporary variable
x["a"] = temp # then, write it back
print(x["a"]) # now, we get ["b"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqlitecollections-0.5.1.tar.gz
(11.3 kB
view hashes)
Built Distribution
Close
Hashes for sqlitecollections-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 025a4561b78ef6720d257e9ab97828bb1e5f6167e6a465b2b6c539ce901838e4 |
|
MD5 | 43c386a64e46427604d3f94e8f45ed5e |
|
BLAKE2b-256 | 1036e6d3c496dd88268390718e33744a01eeb305c415efd8814b2154db1b463f |