Feat v0.7.11 query http ergonomics (#65)
All checks were successful
CI/CD / test-frontend (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m53s
CI/CD / test-sqlite (push) Successful in 2m57s
CI/CD / build-and-deploy (push) Successful in 1m13s
CI/CD / detect-changes (push) Successful in 3s
All checks were successful
CI/CD / test-frontend (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m53s
CI/CD / test-sqlite (push) Successful in 2m57s
CI/CD / build-and-deploy (push) Successful in 1m13s
CI/CD / detect-changes (push) Successful in 3s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #65.
This commit is contained in:
@@ -117,6 +117,25 @@ tables = db.list_tables()
|
||||
|
||||
Available views: `users`, `channels`.
|
||||
|
||||
#### Aggregate operations
|
||||
|
||||
```python
|
||||
# Count rows matching filters
|
||||
count = db.count("tasks", filters={"status": "open"})
|
||||
|
||||
# Aggregate a column (sum, avg, min, max, count)
|
||||
total = db.aggregate("orders", "amount", "sum", filters={"status": "paid"})
|
||||
# Returns int, float, or None (if no matching rows)
|
||||
|
||||
# Batch multiple queries in a single call
|
||||
results = db.query_batch([
|
||||
{"table": "tasks", "filters": {"status": "open"}, "limit": 10},
|
||||
{"table": "logs", "order": "-created_at", "limit": 5},
|
||||
])
|
||||
# Returns list of result lists. Max 10 queries per batch.
|
||||
# Each query spec supports: table (required), filters, order, limit, before, after, search_like
|
||||
```
|
||||
|
||||
#### Write operations
|
||||
|
||||
```python
|
||||
@@ -154,6 +173,18 @@ Response dict:
|
||||
}
|
||||
```
|
||||
|
||||
#### Batch requests
|
||||
|
||||
```python
|
||||
responses = http.batch([
|
||||
{"method": "GET", "url": "https://api.example.com/a"},
|
||||
{"method": "POST", "url": "https://api.example.com/b", "body": "{}", "headers": {"Content-Type": "application/json"}},
|
||||
])
|
||||
# Returns list of response dicts (same shape as individual calls).
|
||||
# Individual failures return {"status": 0, "body": "error: ...", "headers": {}}.
|
||||
# Max 10 requests per batch. Dispatched concurrently.
|
||||
```
|
||||
|
||||
**Security:**
|
||||
- Private/loopback IPs are blocked (SSRF protection).
|
||||
- Packages can declare `network_access.allow` (allowlist) or
|
||||
|
||||
Reference in New Issue
Block a user