Skip to content

Commit

Permalink
Describe how to use postgresql in detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Hironsan committed Aug 16, 2022
1 parent 82aeb80 commit edd11d8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ By default, SQLite 3 is used for the default database. If you want to use Postgr
```bash
pip install 'doccano[postgresql]'
```

and set `DATABASE_URL` environment variable according to your PostgreSQL credentials:

```bash
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable"
```
Expand Down
53 changes: 47 additions & 6 deletions docs/install_and_upgrade_doccano.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

Install doccano on local or in the cloud. Choose the installation method that works best for your environment:

- [Install with pip](#install-with-pip)
- [Install with Docker](#install-with-docker)
- [Install with Docker Compose](#install-with-docker-compose)
- [Install from source](#install-from-source)
- [Install to cloud](#install-to-cloud)
- [Upgrade doccano](#upgrade-doccano)
- [Install doccano](#install-doccano)
- [System requirements](#system-requirements)
- [Web browser support](#web-browser-support)
- [Port requirements](#port-requirements)
- [Install with pip](#install-with-pip)
- [Use PostgreSQL](#use-postgresql)
- [Install with Docker](#install-with-docker)
- [Build a local image with Docker](#build-a-local-image-with-docker)
- [Install with Docker Compose](#install-with-docker-compose)
- [Install from source](#install-from-source)
- [Backend](#backend)
- [Frontend](#frontend)
- [How to create a Python package](#how-to-create-a-python-package)
- [Install to cloud](#install-to-cloud)
- [Upgrade doccano](#upgrade-doccano)
- [After v1.6.0](#after-v160)
- [Before v1.6.0](#before-v160)

## System requirements

Expand Down Expand Up @@ -54,6 +65,36 @@ doccano task

Open <http://localhost:8000/>.

### Use PostgreSQL

By default, SQLite 3 is used for the default database system. You can also use other database systems like PostgreSQL, MySQL, and so on. Here we will show you how to use PostgreSQL.

First, you need to install `psycopg2-binary` as an additional dependency:

```bash
pip install psycopg2-binary
```

Next, set up PostgreSQL. You can set up PostgreSQL directly, but here we will use Docker. Let's run the `docker run` command with the user name(`POSTGRES_USER`), password(`POSTGRES_PASSWORD`), and database name(`POSTGRES_DB`). For other options, please refer to the [official documentation](https://hub.docker.com/_/postgres).

```bash
docker run -d \
--name doccano-postgres \
-e POSTGRES_USER=doccano_admin \
-e POSTGRES_PASSWORD=doccano_pass \
-e POSTGRES_DB=doccano \
-v doccano-db:/var/lib/postgresql/data \
-p 5432:5432 \
postgres:13.8-alpine
```

Then, set `DATABASE_URL` environment variable according to your PostgreSQL credentials. The schema is in line with dj-database-url. Please refer to the [official documentation](https://github.com/jazzband/dj-database-url) for the detailed information.

```bash
# export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable"
export DATABASE_URL="postgres://doccano_admin:doccano_pass@localhost:5432/doccano?sslmode=disable"
```

## Install with Docker

doccano is also available as a [Docker](https://www.docker.com/) container. Make sure you have Docker installed on your machine.
Expand Down

0 comments on commit edd11d8

Please sign in to comment.