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.4-cp38-abi3-win_amd64.whl (5.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

dlens_py-1.0.4-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.4-cp38-abi3-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

dlens_py-1.0.4-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.4-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: dlens_py-1.0.4-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.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0ade43a045731e6db1a76952a7f526e898a23f910e6a300157ff51fe93f194c1
MD5 d1444c9d9d7a294e3b59495ba9f805c0
BLAKE2b-256 4fc0c6e03f2137cb508d099924e2aa3652abe74957ffa579c6850466c18cbc4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.4-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.4-cp38-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.4-cp38-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 9591d6542a2b9516c0401002a735818c371f17d73a883c429404e69dfb67dad1
MD5 5add9e5c031ded26ecc3ab4e80811162
BLAKE2b-256 3aa0e0bd93686897f789bee8ef30216568103aaa6d2fdac8c18076be628fe4fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.4-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.4-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.4-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a6f8dc0eb6023bf36e7daf5fad33c22525e4bbd831d2a768ac225ae5698a9a15
MD5 571457c2592c1211ae553dc97f87cace
BLAKE2b-256 680051042cd6a743046969eca10fdd6a5f4183719669058fdc4140660644dfee

See more details on using hashes here.

Provenance

The following attestation bundles were made for dlens_py-1.0.4-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.4-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dlens_py-1.0.4-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8553b6f33e02019e738372302f65b0ca9119d026a2181f0c202cb425ef48be3a
MD5 13e3c71668d4532e82c60ea2dc1d8939
BLAKE2b-256 3f0b7dae3ac2b93409bf433c44fc30c005717cb882323a730be2a300d37ed611

See more details on using hashes here.

Provenance

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