Skip to main content

Work library for Forge

Project description

forge-db

Use Postgres for local Django development via Docker.

Installation

Forge installation

The forge-db package is a dependency of forge and is available as forge db.

If you use the Forge quickstart, everything you need will already be set up.

The standard Django installation can give you an idea of the steps involved.

Standard Django installation

This package can be used without forge by installing it as a regular Django app.

First, install forge-db from PyPI:

pip install forge-db

Then add it to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    ...
    "forgedb",
]

Now you will have access to the db command:

python manage.py db

You will need to have a DATABASE_URL environment variable, which is where the database name, username, password, and port are parsed from:

# .env
DATABASE_URL=postgres://postgres:postgres@localhost:54321/postgres

You can use a POSTGRES_VERSION environment variable to override the default Postgres version (13):

# .env
POSTGRES_VERSION=12

In most cases you will want to use dj_database_url in your settings.py to easily set the same settings (works in most deployment environments too):

# settings.py
import dj_databse_url

DATABASES = {
    "default": dj_database_url.parse(
        environ["DATABASE_URL"], conn_max_age=environ.get("DATABASE_CONN_MAX_AGE", 600)
    )
}

You will also notice a new .forge directory in your project root. This contains your local database files and should be added to .gitignore.

Usage

If you use forge-work, then most of the time you won't need to interact with forge-db directly. But it has a few commands that come in handy.

  • forge db start - starts a new database container and runs it in the background (use --logs to foreground it or connect to the logs)
  • forge db stop - stop the database container
  • forge db reset - drops and creates a new database
  • forge db pull - pulls the latest database backup from Heroku and imports it into the local database

In the end, the database container is like any other Docker container. You can use the standard Docker commands and tools to interact with it when needed.

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

forge-db-0.3.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

forge_db-0.3.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file forge-db-0.3.0.tar.gz.

File metadata

  • Download URL: forge-db-0.3.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.5 Linux/5.15.0-1014-azure

File hashes

Hashes for forge-db-0.3.0.tar.gz
Algorithm Hash digest
SHA256 537e4989882404e360fd03b63666e2e5f3c95deaab5aa67644670160f681b9e3
MD5 6669a57c5fc5c8d852f5a02e24fc2e33
BLAKE2b-256 1bbd22711f275fb462befd6df91758f300f996b37ec478c2d0a2f79644aab770

See more details on using hashes here.

File details

Details for the file forge_db-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: forge_db-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.10.5 Linux/5.15.0-1014-azure

File hashes

Hashes for forge_db-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94c1f1d104de7d4e66144d5c28e58b86b6ca4d276804b5a255f4e862f8b2293e
MD5 7e88bd63fd7660cedd2408495998b269
BLAKE2b-256 5bb5340c39d1f4022bfdb3c216d29ba2e114e043fd003a996232d500d7b6fec1

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