https://github.com/leits/aiodeta
asyncio client for Deta Cloud (https://deta.sh)
https://github.com/leits/aiodeta
asyncio deta python
Last synced: 10 months ago
JSON representation
asyncio client for Deta Cloud (https://deta.sh)
- Host: GitHub
- URL: https://github.com/leits/aiodeta
- Owner: leits
- License: mit
- Created: 2021-08-15T19:02:39.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-18T22:14:15.000Z (over 4 years ago)
- Last Synced: 2025-05-05T15:56:46.527Z (10 months ago)
- Topics: asyncio, deta, python
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 19
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aiodeta
[](https://github.com/leits/aiodeta/actions/workflows/testing.yml)
[](https://codecov.io/gh/leits/aiodeta)
[](https://badge.fury.io/py/aiodeta)
Unofficial client for [Deta Clound](https://deta.sh)
## Install
```shell
pip install aiodeta
```
## Supported functionality
- [x] Deta Base
- [ ] Deta Drive
- [ ] Decorator for cron tasks
## Examples
```python
import asyncio
from aiodeta import Deta
DETA_PROJECT_KEY = "xxx_yyy"
async def go():
db_name = "users"
# Initialize Deta client
deta = Deta(DETA_PROJECT_KEY)
# Initialize Deta Base client
base = deta.Base(db_name)
# Create row in Deta Base
user = {"username": "steve", "active": False}
resp = await base.insert(user)
print(resp)
user_key = resp["key"]
# Update row by key
resp = await base.update(user_key, set={"active": True})
print(resp)
# Get row by key
resp = await base.get(user_key)
print(resp)
# Delete row by key
resp = await base.delete(user_key)
print(resp)
# Create multiple rows in one request
users = [
{"username": "jeff", "active": True},
{"username": "rob", "active": False},
{"username": "joe", "active": True}
]
resp = await base.put(users)
print(resp)
# Query data
query = [{"active": True}, {"username?pfx": "j"}]
result = await base.query(query=query, limit=10)
print(result)
# Close connection
await deta.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(go())
```