Key-Value Model for Detabase
API
constructor
class KVModel(dict)
example:
from kv_deta import KVModel
class Example(KVModel):
class Config(KVModel.Config):
deta_key = DETA_BASE_KEY
# or
deta = Deta(DETA_BASE_KEY)
table_name = "my_kv_table" # optional
time_to_live = None # int seconds from now(). takes precedence over expire!
expire = None # ISO string or int unix timestamp
hash = my_hash_function # default lambda x: hashlib.sha256(str(x).encode('utf8')).hexdigest()
kv = Example({"key":"value"})
update
kv.update({"k2":42})
as in dictionary
save
kv.save()
commit all data to detabase
get
mixed dict.get(key) & deta.get(key) & dict.setdefault(key, default)
kv.get(key="some key"[, default="default"])
returns value from deta.get(key) or set it by default if deta.get() returned None
delete
kv.delete(key) -> self
delete key from self & base
keys
kv.keys(param=None) -> List
return list(key)
incr, decr
based on Deta.Base.Util.incremental()
kv.incr(key="counter"[, quantity=1])
returns incremented value for key.
if detabase have not specific key, creates it and set value=quantity
query
@classmethod
kv.query(param=criteria, limit=1000, last=None) -> Dict
- return dict(key:value)
- query param see also https://deta.space/docs/en/build/reference/deta-base/queries
read
kv.read(param=criteria, limit=1000, last=None) -> self
- call query() and replaces all data in current model object
Table Struct
| field | description |
|---|---|
| key | hash(key) |
| path | origin key, hidden field |
| value | data |
News
-
v0.2.1, v0.2.2 method delete(), refactor
-
v0.1.23 TTL added
-
v0.1.22 bigint bug is not a bug
Base currently supports maximum 16 digit numbers (integers and floating points), please store larger numbers as a string.
@classmethod query() -> dictby rules. you can search key(s) like an other ordinary fieldsread()uses query() and replaces all data in current model without creating new dictionary object
-
v0.1.20 methods implementation exchanged
incr2 <--> incr -
bug detected: Deta.Base.Util.incremental() doesn't work with bigint
-
v0.1.18 setup repaired
-
v0.1.17 hotfix
-
v0.1.16
query(), keys() -
v0.1.15
rename() -
v0.1.13 backward compatibility broken
-
v0.1.12
incr()rewritten with Deta.Base.Util.incremental() -
v0.1.11
incr(key: str, quantity=1),decr(key: str, quantity=1): return incr(key, -quantity) -
v0.1.8
get()fix -
get(key, default) -
save()
License
- It's opensource and free software, see the LICENSE for more details
similar projects
TODO
- save() refactor
- del
- set()
- TTL
-
incr(),decr() -
query()return dict -
rename(key, new_key) -
keys()get keys list -
get(key)
Metadata
Release files for kv-deta 0.2.2.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kv_deta-0.2.2.post1-py3-none-any.whl | Python 3 | none | any | Details for kv_deta-0.2.2.post1-py3-none-any.whl |
Release files / kv_deta-0.2.2.post1-py3-none-any.whl
| Download URL | kv_deta-0.2.2.post1-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
769ee1262f9437855f830cc12b53511d1efb0c9078dbeb1b159c62d27460e4a2
|
|
BLAKE2b-256 checksum How to use checksums |
2661dacf593c06524ad8ca0a44daf58710039a9255acb5b078af79c8c11c937c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for kv-deta 0.2.2.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.