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.3-cp312-cp312-manylinux_2_39_x86_64.whl (6.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

dlens_py-1.0.3-cp312-cp312-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dlens_py-1.0.3-cp312-cp312-macosx_10_12_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file dlens_py-1.0.3-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.3-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 2ff18e1c577a85949048b6ab8519dc397ddc62677a6f9f7f9e4e1d945b81972c
MD5 9258762c71ed5b2462c7dca1ad6f1b73
BLAKE2b-256 6d5dd1b97b2ef85b5cfafd950b29fd2200b305d7ecc26f436a7b63675093cbfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.3-cp312-cp312-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.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34b42d910c42efc1636cfdee759315dee7bdd394e064fac23108d1159daf4b01
MD5 92930751e7b88823b60595f9650e2bc6
BLAKE2b-256 13c1ba7e62b0cbec2efadbd858997963a42425f878f199d29d56ed89ae286429

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.3-cp312-cp312-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.3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7f8d15b69ba254f348626494577df84aff1f5b153309b593301ec12d7642a28b
MD5 952a6e641a68f18a2d457e7674c7e96a
BLAKE2b-256 540f65ff4ba8ea7869ec07454788cb3de99cb03ffaa25ca47e32a8ecfc55ba22

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.3-cp312-cp312-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