Skip to main content

Manage sqlalchemy connections to local test and prod db's

Project description

Suppose you’re working on a project that uses Google App Engine, Google Cloud SQL, and sqlalchemy. In the course of testing, deploying etc., we want to connect to a couple of databases in different ways:

  • App Engine project talking to production db

  • Local tools (like mysql client or alembic) talking to production db

  • Tests talking to local db

  • Local tools talking to local db

Getting all the connections strings etc. right is kind annoying. This package helps solve that problem.

We assume you have your project’s source on your system at PROJECT_ROOT/, where PROJECT_ROOT is probably something like ~/src/<project_name>. The file layout should look something like this:

├── <project_name>/
│   ├── __init__.py
│   ├── config.yaml
│   ├── alembic.ini
│   ├── lib
│   ├── models.py
│   └── main.py
├── README.md
├── appengine_config.py
└── app.yaml

This package assumes there are three particular files to be available in your system:

  • ~/.<project name>/config.yaml

    ---
    cloud:
        USER: "root"
        PASSWORD: ...
    local:
        USER: "root"
        PASSWORD: ...
        HOST: "localhost"
        PORT: 3306
  • ~/.<project name>/auth-token.json: This is your proxy’s user account auth token.

  • PROJECT_ROOT/<project name>/config.yaml

    ---
    INSTANCE_CONNECTION_NAME: ...

Installing this package (into a virtualenv!) provides the command line script start_cloud_proxy, which starts the Google Cloud SQL proxy for you. In order for this script (and basically everything else in this package) to work, you must first set the SQL_PROJECT_NAME environment variable with value <project_name> (see above file layout).

Release

$ python setup.py register -r pypi(test)
$ python setup.py sdist upload -r pypi(test)

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

sqlemon-0.3.tar.gz (3.7 MB view details)

Uploaded Source

File details

Details for the file sqlemon-0.3.tar.gz.

File metadata

  • Download URL: sqlemon-0.3.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sqlemon-0.3.tar.gz
Algorithm Hash digest
SHA256 00a7ff053a603a3daa10090ec17183b61bed7df12ad8db53971cb9d369f7d3ff
MD5 973b8f5c0869eaf4df8a7ba55b90f309
BLAKE2b-256 1f62ed5f1d4ea730efe8d1dc9ba90c1ed490c344b665fd6e2109cffb8e75a500

See more details on using hashes here.

Supported by

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