Skip to main content

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

License: MIT Python 3.8+ Rust 2024

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dlens_py-1.0.5-cp38-abi3-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

dlens_py-1.0.5-cp38-abi3-manylinux_2_39_x86_64.whl (6.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.39+ x86-64

dlens_py-1.0.5-cp38-abi3-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

dlens_py-1.0.5-cp38-abi3-macosx_10_12_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file dlens_py-1.0.5-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: dlens_py-1.0.5-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 5.6 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dlens_py-1.0.5-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 499c58bddddd40245e3f79ee39cb36cdd4d5961c41147a84acaddc7d7bdc7300
MD5 79824dfb0684edddf5a05cce8deb883a
BLAKE2b-256 cb988a34d4f39d99923862a08678d3f60c860d7c3e59597960ec472d5aa7a9c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.5-cp38-abi3-win_amd64.whl:

Publisher: publish.yml on CharFranR/Docker-Lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dlens_py-1.0.5-cp38-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.5-cp38-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 2bf3adbd167c9c4bc061a4839d18658d63bf48e628bb28090a4937070693f5bd
MD5 80dacd8b5bb856e40ad80c15c4dad88c
BLAKE2b-256 fd1c6e19fb3b1d9ba95469d5e5a2f75c0c673b007f42175d54b128e2fad6c9ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.5-cp38-abi3-manylinux_2_39_x86_64.whl:

Publisher: publish.yml on CharFranR/Docker-Lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dlens_py-1.0.5-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.5-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d278d33e693bffa8f1c2bc71f187c9b97c1a6efee30904662a8157d5179a6a0f
MD5 54c03a12707e539cb31f5601160c5385
BLAKE2b-256 e0c98fa61cc89a38c16e7035e349efe1783b57c5d2684e367f9193e39bbc9f75

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.5-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on CharFranR/Docker-Lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dlens_py-1.0.5-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.5-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e4bbcfd4a15feba65e86cba85739db4ce27d0d769498a5d0cb65a62a1cf7693d
MD5 023a252dd7c49143c85ad04fc58f029a
BLAKE2b-256 d8a995e4a734530b0def3368bd5cc611c14404f7336e7f13af704d68886e8e40

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.5-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on CharFranR/Docker-Lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page