# forge-db
Use Postgres for local Django development via Docker.
## Installation
First, install `forge-db` from [PyPI](https://pypi.org/project/forge-db/):
```sh
pip install forge-db
```
Now you will have access to the `db` command:
```sh
forge db
```
You will need to have a `DATABASE_URL` environment variable,
which is where the database name, username, password, and port are parsed from:
```sh
# .env
DATABASE_URL=postgres://postgres:postgres@localhost:54321/postgres
```
You can use a `POSTGRES_VERSION` environment variable to override the default Postgres version (13):
```sh
# .env
POSTGRES_VERSION=12
```
In most cases you will want to use [`dj_database_url`](https://github.com/kennethreitz/dj-database-url) in your `settings.py` to easily set the same settings (works in most deployment environments too):
```python
# 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`](https://github.com/forgepackages/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.
Raw data
{
"_id": null,
"home_page": "https://www.forgepackages.com/",
"name": "forge-db",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "django,saas,forge,framework",
"author": "Dave Gaeddert",
"author_email": "dave.gaeddert@dropseed.dev",
"download_url": "https://files.pythonhosted.org/packages/b2/fe/011b368ec2bdeda217afee38747a428d32a381958db6b33ce4317b9a69dd/forge_db-1.0.0.tar.gz",
"platform": null,
"description": "# forge-db\n\nUse Postgres for local Django development via Docker.\n\n\n## Installation\n\nFirst, install `forge-db` from [PyPI](https://pypi.org/project/forge-db/):\n\n```sh\npip install forge-db\n```\n\nNow you will have access to the `db` command:\n\n```sh\nforge db\n```\n\nYou will need to have a `DATABASE_URL` environment variable,\nwhich is where the database name, username, password, and port are parsed from:\n\n```sh\n# .env\nDATABASE_URL=postgres://postgres:postgres@localhost:54321/postgres\n```\n\nYou can use a `POSTGRES_VERSION` environment variable to override the default Postgres version (13):\n\n```sh\n# .env\nPOSTGRES_VERSION=12\n```\n\nIn most cases you will want to use [`dj_database_url`](https://github.com/kennethreitz/dj-database-url) in your `settings.py` to easily set the same settings (works in most deployment environments too):\n\n```python\n# settings.py\nimport dj_databse_url\n\nDATABASES = {\n \"default\": dj_database_url.parse(\n environ[\"DATABASE_URL\"], conn_max_age=environ.get(\"DATABASE_CONN_MAX_AGE\", 600)\n )\n}\n```\n\nYou will also notice a new `.forge` directory in your project root.\nThis contains your local database files and should be added to `.gitignore`.\n\n## Usage\n\nIf you use [`forge-work`](https://github.com/forgepackages/forge-work),\nthen most of the time you won't need to interact with `forge-db` directly.\nBut it has a few commands that come in handy.\n\n- `forge db start` - starts a new database container and runs it in the background (use `--logs` to foreground it or connect to the logs)\n- `forge db stop` - stop the database container\n- `forge db reset` - drops and creates a new database\n- `forge db pull` - pulls the latest database backup from Heroku and imports it into the local database\n\nIn the end, the database container is like any other Docker container.\nYou can use the standard Docker commands and tools to interact with it when needed.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Work library for Forge",
"version": "1.0.0",
"split_keywords": [
"django",
"saas",
"forge",
"framework"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a5847191411b35e4fc316699bec563ba38242658cfd9df06bc29900304a36a62",
"md5": "b08fae7cb885047d1fb3766a979f5b25",
"sha256": "9530161473bd3e9e2d6a590dc952a793b06153ce81243a977aeffaba580b5a6f"
},
"downloads": -1,
"filename": "forge_db-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b08fae7cb885047d1fb3766a979f5b25",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 7485,
"upload_time": "2023-01-20T02:45:57",
"upload_time_iso_8601": "2023-01-20T02:45:57.645368Z",
"url": "https://files.pythonhosted.org/packages/a5/84/7191411b35e4fc316699bec563ba38242658cfd9df06bc29900304a36a62/forge_db-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b2fe011b368ec2bdeda217afee38747a428d32a381958db6b33ce4317b9a69dd",
"md5": "0de2b02e8a5ad20178107e886114032e",
"sha256": "3cec42123989a5ab8436683cdbfdd3a1e75ce72db95e5f6f595ce6372bed0844"
},
"downloads": -1,
"filename": "forge_db-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "0de2b02e8a5ad20178107e886114032e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 6663,
"upload_time": "2023-01-20T02:45:59",
"upload_time_iso_8601": "2023-01-20T02:45:59.523235Z",
"url": "https://files.pythonhosted.org/packages/b2/fe/011b368ec2bdeda217afee38747a428d32a381958db6b33ce4317b9a69dd/forge_db-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-20 02:45:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "forge-db"
}