kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Add instructions for running with postgresql locally (and production?) in dev docs

Open jonboiser opened this issue 5 years ago • 6 comments

I don't think there are instructions on how to set up Kolibri to use Postgres as an alternative DB. Here's what @lyw07 shared with me on how to do it:

  1. Install postgresql (brew install postgresql if you have mac + homebrew)
  2. install psycopg2-binary from pip (pip install psycog2-binary)
  3. set env var KOLIBRI_DATABASE_ENGINE to postgres
  4. set other env vars KOLIBRI_DATABASE_NAME, KOLIBRI_DATABASE_PASSWORD, KOLIBRI_DATABASE_USER, KOLIBRI_DATABASE_HOST, and KOLIBRI_DATABASE_PORT

Example .env file

KOLIBRI_DATABASE_ENGINE = postgres
KOLIBRI_DATABASE_NAME = postgres
KOLIBRI_DATABASE_PASSWORD = postgres
KOLIBRI_DATABASE_USER = [shell username]
KOLIBRI_DATABASE_HOST = 127.0.0.1
KOLIBRI_DATABASE_PORT = 5432

May also need to delete ~/.kolibri/.data_version if already started server with sqlite.

jonboiser avatar Feb 12 '20 21:02 jonboiser

Thanks, yes. This was discussed in the last dev meeting

@cpauya made a good initial start of instructions here: https://github.com/learningequality/kolibri/issues/6480#issuecomment-583299221

indirectlylit avatar Feb 12 '20 23:02 indirectlylit

  • We should add instructions to create the initial database
  • pip install psycog2 should be instead of pip install psycog2-binary
  • the user credentials and database name will depend on your postgresql instalation (and location, if it is in another server)

jredrejo avatar Nov 04 '20 13:11 jredrejo

I think Lingyi used psycog2-binary for a specific reason I can't remember. Is using psycog2 something we should do because of a recent change?

jonboiser avatar Nov 04 '20 17:11 jonboiser

There are more details on how to make the initial database table in this comment: https://github.com/learningequality/kolibri/issues/6480#issuecomment-583299221

I think a script file that someone could pipe into the postgres interpreter would be convenient.

jonboiser avatar Nov 04 '20 17:11 jonboiser

I think Lingyi used psycog2-binary for a specific reason I can't remember. Is using psycog2 something we should do because of a recent change?

lol I used psycopg2 because I could not find in psycog2-binary in pip. The reason was I copied and pasted from your comment and there's a missing p in the package name. If you fix it, it's fine as installing the binary avoids the compilation phase in pip

jredrejo avatar Nov 04 '20 18:11 jredrejo

This PR by @bjester https://github.com/learningequality/kolibri/pull/9556 added some make commands to make this easier, but instructions would finalize this issue!

rtibbles avatar Aug 29 '22 23:08 rtibbles