# Unable to change SQLite database to Postgres in options.ini file

**URL:** <https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916>\
**Category:** Kolibri\
**Created:** [February 25, 2021, 1:49pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916 "2021-02-25T13:49:59Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [February 25, 2021, 1:49pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/1 "2021-02-25T13:49:59Z")

</div>

Hi

## Summary

I want to change the database from SQLite to Postgres and configured the options.ini file. But when I try to migrate it keeps ignoring the options.ini configurations.

Any help!

## Technical details

- Kolibri version
- Operating system
- Browser

---

<div class="post-metadata">

**Author:** ![blaine](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/blaine/32/479_2.png) [@blaine](https://community.learningequality.org/u/blaine)\
**Post date:** [February 25, 2021, 11:33pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/2 "2021-02-25T23:33:38Z")

</div>

Hi @mikiasephrem,

Sorry to hear you’re running into issues.

Would you please provide the following information:

- the version of Kolibri you’re using,
- the operating system Kolibri is installed on, and
- the contents of the `options.ini` file

Regards,  
Blaine

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [February 26, 2021, 1:53am UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/3 "2021-02-26T01:53:09Z")

</div>

Hi @blaine,

Thanks for the response.

Kolibri version = 0.14.3  
OS = Ubuntu 16.04  
Contents of Options.ini

[Database]  
DATABASE\_ENGINE=“postgres”  
DATABASE\_NAME=“db\_name”  
DATABASE\_HOST=“localhost”  
DATABASE\_USER=“db\_user”  
DATABASE\_PASSWORD=“db\_user\_password”  
DATABASE\_PORT = 5432

I tried it without the double quotes too. No other values are changed other than this.

---

<div class="post-metadata">

**Author:** ![blaine](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/blaine/32/479_2.png) [@blaine](https://community.learningequality.org/u/blaine)\
**Post date:** [March 1, 2021, 10:37pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/4 "2021-03-01T22:37:34Z")

</div>

Hi @mikiasephrem,

Thank you. Luckily for my sake at least, you omitted or didn’t include sensitive information from the `options.ini` contents. Please make sure of that going forward.

Have you created a user and database within PostgreSQL for those parameters, for example: database name, user, and password? And you’re able to connect to the database using [`psql` CLI](https://www.postgresql.org/docs/10/app-psql.html)? A command like this should tell you if it can connect, using the info from above (enter the password when it prompts):

```auto
$ psql --host=localhost --username=db_user --password --command="select 'Yes, connection works';" db_name

```

If you see `Yes, connection works` in the output, then the connection is working.

Please note, there is currently no automated functionality that will migrate the SQLite database contents to the PostgreSQL database. One manual option is to use a [tool called `pgloader`](https://pgloader.readthedocs.io/en/latest/ref/sqlite.html).

Regards,  
Blaine

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 3, 2021, 1:58pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/5 "2021-03-03T13:58:43Z")

</div>

Hi @blaine,

Thanks for your response. I upgraded my Kolibri to 0.14.6 and it is giving me the following error.

 ![kolibri error](https://canada1.discourse-cdn.com/flex035/uploads/learneq/original/1X/ead9f31f2edb248f0660ab147fa498ec0e87f361.png)

---

<div class="post-metadata">

**Author:** ![blaine](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/blaine/32/479_2.png) [@blaine](https://community.learningequality.org/u/blaine)\
**Post date:** [March 3, 2021, 4:46pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/6 "2021-03-03T16:46:54Z")

</div>

@mikiasephrem

Did you perhaps still have the custom database configuration in Kolibri’s `options.ini` file? If so, you might try removing that configuration, and restarting Kolibri.

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 4, 2021, 9:16am UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/7 "2021-03-04T09:16:18Z")

</div>

@blaine

I did remove the configuration in Kolibri’s `option.ini` file and restarted Kolibri. It is the same error.

---

<div class="post-metadata">

**Author:** ![blaine](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/blaine/32/479_2.png) [@blaine](https://community.learningequality.org/u/blaine)\
**Post date:** [March 4, 2021, 11:36pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/8 "2021-03-04T23:36:43Z")

</div>

@mikiasephrem

Thanks for checking the `options.ini`. I attempted to reproduce your issue but I wasn’t able to. I do have two ideas for debugging:

1. The error is coming from a `pysqlite2` package, which my Kolibri doesn’t seem to need or use. I was able to install it using `pip install pysqlite` creating a `pysqlite2` directory, and also required installing `libsqlite3-dev`. Do you recall having to install those manually? If so, you might try re-installing them.
2. It’s possible there’s an issue with the database file. If it’s possible for you to send me the database file, that would be helpful in debugging your issue. Please send me a direct message if you’re willing to send it.

Regards,  
Blaine

---

<div class="post-metadata">

**Author:** ![blaine](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/blaine/32/479_2.png) [@blaine](https://community.learningequality.org/u/blaine)\
**Post date:** [March 5, 2021, 4:58pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/9 "2021-03-05T16:58:36Z")

</div>

Hi @mikiasephrem,

I have some new insight for you, thanks to my co-worker Jamie who randomly ran across something that could be related to this. He found when performing a SQL dump from PostgreSQL, it quoted a column named `order` as seen in the image below. In combination with your screenshot of the error, which says error near `"order"`, it seems it could be related to setting up Kolibri with PostgreSQL?

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/learneq/original/1X/431f6feb62189ea4e2dafe35e1d90db3fa268f7c.png)

Regards,  
Blaine

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 8, 2021, 11:25am UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/10 "2021-03-08T11:25:02Z")

</div>

Hi @blaine

Thanks for following up on this and sorry for the late replay. I think you are right. Is there any documentation on setting up Kolibri with PostgreSQL? if you don’t mind me asking.

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 8, 2021, 12:46pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/11 "2021-03-08T12:46:30Z")

</div>

Hi @blaine,

Just want to update you on this. I have managed to configure PostgreSQL with Kolibri without any data in it but the Kolibri is not starting up. Here is the terminal screenshot and log file.

Please note that the option.ini settings are ignored.

 ![kolibri](https://canada1.discourse-cdn.com/flex035/uploads/learneq/original/1X/2b542430d1106f19204b3ffae4ca9e2dba9a3775.png)

INFO 2021-03-08 15:29:05,619 kolibri.utils.cli Going to background mode, logging to /root/.kolibri/logs/kolibri.txt  
INFO 2021-03-08 15:29:05,627 kolibri.utils.server Starting Kolibri 0.14.6  
INFO 2021-03-08 15:29:05,648 cherrypy.error ENGINE Listening for SIGHUP.  
INFO 2021-03-08 15:29:05,649 cherrypy.error ENGINE Listening for SIGUSR1.  
INFO 2021-03-08 15:29:05,649 cherrypy.error ENGINE Listening for SIGTERM.  
INFO 2021-03-08 15:29:05,649 cherrypy.error ENGINE Listening for SIGINT.  
INFO 2021-03-08 15:29:05,650 cherrypy.error ENGINE Bus STARTING  
ERROR 2021-03-08 15:29:05,681 cherrypy.error ENGINE Error in ‘start’ listener \<bound method ServicesPlugin.start of \<kolibri.utils.server.ServicesPlugin object at 0x7f48db093c50\>\>  
Traceback (most recent call last):  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/cherrypy/process/wspbus.py”, line 230, in publish  
output.append(listener(\*args, \*\*kwargs))  
File “/usr/local/lib/python2.7/dist-packages/kolibri/utils/server.py”, line 87, in start  
scheduler.clear\_scheduler()  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/django/utils/functional.py”, line 238, in inner  
self.\_setup()  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/django/utils/functional.py”, line 386, in \_setup  
self.\_wrapped = self.\_setupfunc()  
File “/usr/local/lib/python2.7/dist-packages/kolibri/core/tasks/main.py”, line 111, in \_\_scheduler  
return Scheduler(queue=queue, connection=connection)  
File “/usr/local/lib/python2.7/dist-packages/kolibri/core/tasks/scheduler.py”, line 63, in **init**  
self.queue = queue(connection=connection)  
TypeError: ‘SimpleLazyObject’ object is not callable

INFO 2021-03-08 15:29:05,784 cherrypy.error ENGINE Serving on [http://0.0.0.0:8080](http://0.0.0.0:8080)  
ERROR 2021-03-08 15:29:05,785 cherrypy.error ENGINE Shutting down due to error in start listener:  
Traceback (most recent call last):  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/cherrypy/process/wspbus.py”, line 268, in start  
self.publish(‘start’)  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/cherrypy/process/wspbus.py”, line 248, in publish  
raise exc  
ChannelFailures: TypeError("‘SimpleLazyObject’ object is not callable",)

INFO 2021-03-08 15:29:05,785 cherrypy.error ENGINE Bus STOPPING  
INFO 2021-03-08 15:29:05,797 cherrypy.error ENGINE HTTP Server cherrypy.\_cpwsgi\_server.CPWSGIServer((‘0.0.0.0’, 8080)) shut down  
ERROR 2021-03-08 15:29:05,799 cherrypy.error ENGINE Error in ‘stop’ listener \<bound method ServicesPlugin.stop of \<kolibri.utils.server.ServicesPlugin object at 0x7f48db093c50\>\>  
Traceback (most recent call last):  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/cherrypy/process/wspbus.py”, line 230, in publish  
output.append(listener(\*args, \*\*kwargs))  
File “/usr/local/lib/python2.7/dist-packages/kolibri/utils/server.py”, line 116, in stop  
scheduler.shutdown\_scheduler()  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/django/utils/functional.py”, line 238, in inner  
self.\_setup()  
File “/usr/local/lib/python2.7/dist-packages/kolibri/dist/django/utils/functional.py”, line 386, in \_setup  
self.\_wrapped = self.\_setupfunc()  
File “/usr/local/lib/python2.7/dist-packages/kolibri/core/tasks/main.py”, line 111, in \_\_scheduler  
return Scheduler(queue=queue, connection=connection)  
File “/usr/local/lib/python2.7/dist-packages/kolibri/core/tasks/scheduler.py”, line 63, in **init**  
self.queue = queue(connection=connection)  
TypeError: ‘SimpleLazyObject’ object is not callable

---

<div class="post-metadata">

**Author:** ![blaine](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/blaine/32/479_2.png) [@blaine](https://community.learningequality.org/u/blaine)\
**Post date:** [March 8, 2021, 10:37pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/12 "2021-03-08T22:37:36Z")

</div>

The error would seem to indicate that you’re missing the `[Database]` line before listing the database specific options in the `options.ini`. You might also check that there’s only one line with `[Database]`. Could you verify that?

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 15, 2021, 5:22am UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/13 "2021-03-15T05:22:07Z")

</div>

@blaine

Thanks, this helps.

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 15, 2021, 5:34am UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/14 "2021-03-15T05:34:48Z")

</div>

@blaine

There seems to be a problem with logging in after frequent usage. It seems that when you click to sign in after you input the username and password, it’s not logging in and the sign-in button is disabled.

[Here is the link for the XHR file](https://drive.google.com/file/d/19hZUicjSQcUi_VA6mzTXeA59fwlVZ8Rx/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![richard](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/richard/32/10_2.png) [@richard](https://community.learningequality.org/u/richard)\
**Post date:** [March 15, 2021, 2:31pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/15 "2021-03-15T14:31:25Z")

</div>

The issue appears to be that it is trying to log in without sending a password. I assume the account you are attempting to login with is an admin account, and that otherwise you have ‘no password required’ for learners set.

Can you confirm that you have this setting set? Also, have any edits been made to the frontend code that differ from Kolibri 0.14.3, as we’ve not had this issue reported previously, and it seems like it would be a common error.

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 15, 2021, 6:12pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/16 "2021-03-15T18:12:17Z")

</div>

Hi @richard,

Thanks for your response.

Yes, you are right, the account I am attempting to log in to is an admin account and I can confirm the settings are set to ‘no password required for learners’. As for the frontend code, I did change the default color of Kolibri nothing more.

I just want to ask one thing, is there any command available to reset the settings? Am asking this because I can’t log in as an admin and can’t even access the settings page. And I don’t know if users changed it too. If a command-line setting reset can be done that might resolve the issue.

Please let me know your thoughts.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.learningequality.org/richard/32/10_2.png) [@richard](https://community.learningequality.org/u/richard)\
**Post date:** [March 15, 2021, 7:03pm UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/17 "2021-03-15T19:03:49Z")

</div>

Hi @mikiasephrem,

You can update these settings through the command line, but you would need to use the Python shell to do so.

You can access this by typing `kolibri shell` in the command line.

The following code entered into the shell should change this setting:

```auto
from kolibri.core.auth.models import FacilityDataset

fd = FacilityDataset.objects.all().get()
fd.learner_can_login_with_no_password = False
fd.save()

```

This should work, unless you have multiple facilities on the device.

If you have multiple facilities on the device, you will need to first get the specific facility you are updating this setting for:

```auto
from kolibri.core.auth.models import Facility

f = Facility.objects.get(name="facilityname")
f.dataset.learner_can_login_with_no_password = False
f.dataset.save()

```

Where `facilityname` is the name of the specific facility you are trying to update.

Kind Regards,  
Richard

---

<div class="post-metadata">

**Author:** ![mikiasephrem](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@mikiasephrem](https://community.learningequality.org/u/mikiasephrem)\
**Post date:** [March 17, 2021, 4:33am UTC](https://community.learningequality.org/t/unable-to-change-sqlite-database-to-postgres-in-options-ini-file/1916/18 "2021-03-17T04:33:45Z")

</div>

Hi @richard,

Thanks for the commands. But the issue is not resolved. I even tried to create an account and once fill in the information and click Finish it give me the same error as the login. I only have one facility but i tried it with both commands too.
