Accedé a tu base de datos desde el terminal. Detecta automáticamente PostgreSQL, MySQL, MariaDB, MongoDB y SQLite en docker-compose.
Project description
Docker-Lens
CLI para acceder a bases de datos en docker-compose sin configuración manual. Detecta el motor, extrae las credenciales y conecta automáticamente.
Prerrequisitos
- Python 3.8+
- Docker corriendo
- Una de las DBs soportadas en tu
docker-compose.yml
Stack
| Capa | Tecnología |
|---|---|
| Core | Rust 2024, PyO3 |
| Docker | bollard (API nativa) |
| CLI | Python 3.8+, Click |
| DBs | psql, mysql CLI, mongodb crate, rusqlite |
Architecture
docker-lens
├── heuristic → Detección de DB en docker-compose.yml (scoring ponderado)
├── db/
│ ├── docker → Resolución de IP via bollard
│ ├── postgres → Adapter psql
│ ├── mysql → Adapter mysql CLI
│ ├── mongo → Adapter mongodb crate (async)
│ └── sqlite → Adapter rusqlite (bundled)
└── cli → Comandos Click (Python)
Quick start
pip install docker-lens
# Info de la DB detectada
docker-lens info .
# Listar tablas
docker-lens tables .
# Query directa
docker-lens query "SELECT * FROM usuarios" .
# Exportar a CSV
docker-lens export-csv usuarios .
# Migrar a SQLite
docker-lens export-sqlite . -o backup.db
El argumento . es la ruta al directorio que contiene tu docker-compose.yml. Puede ser . (directorio actual) o cualquier otra ruta.
Cómo funciona
Docker-Lens analiza tu docker-compose.yml y asigna puntaje a cada servicio según:
- Imagen (30 pts) — coincide con patrones conocidos del motor
- Puerto (25 pts) — expone el puerto por defecto de la DB
- Variables de entorno (15-20 pts) — tiene keys como
POSTGRES_USER,MYSQL_ROOT_PASSWORD, etc. - Nombre del servicio (10 pts) — se llama
db,postgres,mongo, etc.
El servicio con mayor puntaje gana. Las credenciales se extraen de las variables de entorno del compose, con defaults razonables si faltan.
Comandos
| Comando | Descripción |
|---|---|
info |
Credenciales detectadas |
tables |
Lista tablas/collections |
query |
SQL o MongoDB queries |
head / tail |
Primeras / últimas N filas |
schema |
Columnas, tipos y constraints |
count |
Cantidad de filas |
export-csv |
Exporta una tabla a CSV |
export-all |
Exporta todas las tablas |
export-sqlite |
Migra la DB completa a SQLite |
shell |
Sesión interactiva (psql/mysql/mongosh) |
truncate / drop |
Vacía o elimina una tabla |
DBs soportadas
PostgreSQL, MySQL, MariaDB, MongoDB, SQLite. La detección es automática mediante scoring ponderado sobre imagen, puerto y variables de entorno del compose.
Desarrollo
# Build
maturin build --release
# Instalar localmente
pip install target/wheels/*.whl
# Tests
cargo test
Licencia
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dlens_py-1.0.1-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: dlens_py-1.0.1-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 6.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e19b3fcf4fb2ae327f3240b81b8381945a4d8bb5123456e2605cded9385679ee
|
|
| MD5 |
35c8a85a546ff64eec21df17407aae14
|
|
| BLAKE2b-256 |
868325c1321aba90e9ee482bc5b2461dea8af7dd01b063be821234822c1df738
|
Provenance
The following attestation bundles were made for dlens_py-1.0.1-cp312-cp312-manylinux_2_39_x86_64.whl:
Publisher:
publish.yml on CharFranR/Docker-Lens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dlens_py-1.0.1-cp312-cp312-manylinux_2_39_x86_64.whl -
Subject digest:
e19b3fcf4fb2ae327f3240b81b8381945a4d8bb5123456e2605cded9385679ee - Sigstore transparency entry: 1763270265
- Sigstore integration time:
-
Permalink:
CharFranR/Docker-Lens@c0f3297acf7709b9581a8d049907a74f6af8e568 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/CharFranR
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0f3297acf7709b9581a8d049907a74f6af8e568 -
Trigger Event:
push
-
Statement type: