diff --git a/README.md b/README.md index a2befc8f..62e9d173 100644 --- a/README.md +++ b/README.md @@ -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" ``` diff --git a/docs/install_and_upgrade_doccano.md b/docs/install_and_upgrade_doccano.md index f8474bbf..21f8010c 100644 --- a/docs/install_and_upgrade_doccano.md +++ b/docs/install_and_upgrade_doccano.md @@ -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 @@ -54,6 +65,36 @@ doccano task Open . +### 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.