Skip to main content

A connection helper.

Project description

Conexao

A connection helper. Current features:

  • Management of multiple remote MongoDB connection profiles.
  • Faster permanent remote Docker connections.
  • SSH port forward proxies.

Django (ORM)

Add a JSON file to ~/.config/conexao/config.json.

Example:

{
  "profiles": {
    "myapp": {
      "django": {"settings": "myapp.settings"},
      "ssh": {
        "host": "my-vps.example.com",
        "forwards": ["localhost:5432:localhost:5432"]
      }
    }
  }
}

The Django project must be installed in the used Python environment. Maybe doing pip install -e . , from the Django project's folder.

Then use:

from conexao.django import configure
configure('myapp')  # Must come before model import!
from myapp.models import MyModel

MyModel.objects.all()

or:

from conexao.django.auto import myapp  # Must come before model import!
from myapp.models import MyModel

MyModel.objects.all()

MongoDB

Add a JSON file to ~/.config/conexao/config.json.

Example:

{
  "profiles": {
    "simpleMongo": {
      "mongo": {
        "host": "simple-mongo.example.com"
      },
    },
    "mongoInsideDockerVPS": {
      "mongo": {
        "host": "127.0.0.1"
      },
      "ssh": {
        "host": "my-vps.example.com",
        "forwards": ["127.0.0.1:27017:123.docker.container.ip.456:27017"]
      }
    }
  }
}

Then use:

from conexao.mongodb import create_client

client1 = create_client('simpleMongo')
client2 = create_client('mongoInsideDockerVPS')

or:

from conexao.mongodb.auto import simpleMongo as client1, mongoInsideDockerVPS as client2

Docker

Opens a permanent SSH forward for faster remote Docker command execution. Based on: https://forums.docker.com/t/setting-docker-host-to-ssh-results-in-slow-workflow-can-ssh-connection-be-reused/98754

conexao docker <host>

This feature doesn't use the config.json file.

Limitations

This program uses a Python Shelve to store SSH PIDs of all running forwards. Shelve isn't concurrent safe, so avoid calling this program multiple times in parallel. Once the program returns it should be safe to call it again to add more connections.

Development

Install locally using symlinks:

pip install -e .

Build:

python -m build

Publish (need auth):

twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conexao-0.0.11.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

conexao-0.0.11-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file conexao-0.0.11.tar.gz.

File metadata

  • Download URL: conexao-0.0.11.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for conexao-0.0.11.tar.gz
Algorithm Hash digest
SHA256 816f454124a81a4e02f77c93c888bd7b4afb26763476268d20ae1dabde3e4189
MD5 2418371285ebfa7ad9123d1d7e73ad69
BLAKE2b-256 079a2ca12edd7e1f948330e0e4f9e157fdc9add7585a168a955527acaa88e461

See more details on using hashes here.

File details

Details for the file conexao-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: conexao-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for conexao-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 c563788dc3c1113ea6ac31d4dc45fe166646e10a42e5fd041ba81a0cd1df4c48
MD5 1ed1b2d5c2f00367d8c797e95f5a9b90
BLAKE2b-256 d7536890ba18578c91c3825287a82797f0d86b897a33bfffc5b2f4ac69b7922c

See more details on using hashes here.

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