matimo-postgres
PostgreSQL tools for Matimo - execute SQL queries safely with policy-gated approval.
Installation
pip install matimo matimo-postgres
Available Tools (1 Tool)
| Tool | Description |
|---|---|
postgres-execute-sql |
Execute a SQL query against a PostgreSQL database |
The tool does not set requires_approval itself - if you want destructive operations
(INSERT, UPDATE, DELETE, DROP) to require human approval, gate them yourself via a
policy file or a custom
PolicyEngine.
Quick Start
import asyncio
from matimo import Matimo
from matimo_postgres import get_tools_path
async def main():
matimo = await Matimo.init(get_tools_path())
# Run a SELECT query
result = await matimo.execute('postgres-execute-sql', {
'sql': 'SELECT id, name FROM users LIMIT 10',
})
print(result)
asyncio.run(main())
With Interactive Approval (Recommended for Writes)
A query whose sql contains a destructive keyword (DELETE, DROP, UPDATE, INSERT, ALTER, CREATE, ...) needs approval. Provide an on_approval callback; without one the query is refused:
from matimo import ApprovalRequest
async def ask_user(request: ApprovalRequest) -> bool:
print(f"\nSQL requires approval:\n{request.params.get('sql')}")
return input("Run this query? [y/n]: ").strip() == "y"
matimo = await Matimo.init(get_tools_path(), on_approval=ask_user)
# Prompts before executing
await matimo.execute('postgres-execute-sql', {
'sql': 'DELETE FROM sessions WHERE expired_at < NOW()',
})
The keyword match is a substring of the upper-cased query, so a SELECT created_at ... also asks (it contains CREATE).
Authentication
export MATIMO_POSTGRES_URL="postgresql://user:password@localhost:5432/mydb"
# or individual params
export MATIMO_POSTGRES_HOST="localhost"
export MATIMO_POSTGRES_PORT="5432"
export MATIMO_POSTGRES_DB="mydb"
export MATIMO_POSTGRES_USER="myuser"
export MATIMO_POSTGRES_PASSWORD="mypassword"
Security Notes
- All SQL queries go through Matimo's content validator - SSRF and injection patterns are detected
- The tool itself does not require approval - use a policy file if you want writes gated
- Use a read-only database user for agent workloads when possible
- Consider a policy file to restrict allowed SQL patterns
Documentation
Links
Metadata
Release files for matimo-postgres 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matimo_postgres-0.2.0.tar.gz | 7.9 kB | Without provenance | Details for matimo_postgres-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matimo_postgres-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for matimo_postgres-0.2.0-py3-none-any.whl |
Total release size: 17.6 kB
Release files / matimo_postgres-0.2.0.tar.gz
| Download URL | matimo_postgres-0.2.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6dd500cf314d9adbd0a6bfb5d332e2dd1ae75172f83c4ab409b5e0976d3c7983
|
|
BLAKE2b-256 checksum How to use checksums |
cda402df8952f5cb1368f48c98c28a2d7264b62827a1a6933fd046b49b662c50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / matimo_postgres-0.2.0-py3-none-any.whl
| Download URL | matimo_postgres-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e940a5984343612dd4618983362fd16f9ee841412023e66089f9c36b73d40b43
|
|
BLAKE2b-256 checksum How to use checksums |
9a34f56d74a267b9747716fa9bb0d6468f5585136bcccd040c6abbce5357bb7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for matimo-postgres 0.2.0
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.