# SQLite-Database

**URL:** https://discuss.tryton.org/t/sqlite-database/675
**Category:** User
**Created:** [August 24, 2018, 4:44pm UTC](https://discuss.tryton.org/t/sqlite-database/675 "2018-08-24T16:44:40Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![alex](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://discuss.tryton.org/u/alex)
#### Post date: [August 24, 2018, 4:44pm UTC](https://discuss.tryton.org/t/sqlite-database/675/1 "2018-08-24T16:44:40Z")

</div>

Hello!  
I am starting with tryton and would like to have a simple sqlite-database for the very beginning. Unfortunately, I don’t seem to be able to get up and running.

I have installed tryton 4.6.5 from the Ubuntu repos on Ubuntu 18.04.  
From what I can read in the manual, sqlite should be the default option for the data-backend, so no more configuration needed, right?

trytond is running in the background, so I start tryton. This gives me the possibility to connect to [demo.4.6.tryton.org](http://demo.4.6.tryton.org), which works just fine.  
However, I cannot create a new database, neither from the login manager nor do I find an option to do so from the command line.

Please help: how can I ‘connect’ to a local, empty sqlite database?

Thanks!

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 24, 2018, 5:41pm UTC](https://discuss.tryton.org/t/sqlite-database/675/2 "2018-08-24T17:41:48Z")

</div>

SQLite is there only to support the development for quick testing.  
So I suggest you to start directly by using postgresql.  
Here is the documentation to [setup the database](https://tryton-readthedocs.readthedocs.io/projects/server/en/4.8/topics/setup_database.html#topics-setup-database).  
Remarks to create the database:

- with SQLite, you must create an empty file in the database [path](https://tryton-readthedocs.readthedocs.io/projects/server/en/4.8/topics/configuration.html#path),
- with PostgreSQL, you must run the command [`createdb`](https://www.postgresql.org/docs/current/static/app-createdb.html).

---

<div class="post-metadata">

### Author: ![alex](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://discuss.tryton.org/u/alex)
#### Post date: [August 24, 2018, 7:04pm UTC](https://discuss.tryton.org/t/sqlite-database/675/3 "2018-08-24T19:04:01Z")

</div>

Thank you for the clarification!

Regarding the path: I tried that. I set the path property to my own home directory and created both ‘tryton.db’ and ‘tryton.sqlite’ (both empty). Then in the login manager, I set host to ‘localhost’, database to ‘tryton’ and leave the user name empty. When I try to connect I get a python traceback claiming that ‘tryton.sqlite’ is missing?!

I’ll try the PostgreSQL variant, though…

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 24, 2018, 9:04pm UTC](https://discuss.tryton.org/t/sqlite-database/675/4 "2018-08-24T21:04:42Z")

</div>

> [@alex](#):
>
> Regarding the path: I tried that. I set the path property to my own home directory and created both ‘tryton.db’ and ‘tryton.sqlite’ (both empty). Then in the login manager, I set host to ‘localhost’, database to ‘tryton’ and leave the user name empty. When I try to connect I get a python traceback claiming that ‘tryton.sqlite’ is missing?!

You must initialize the database with `trytond-admin` as describe in the documentation.  
The user name created by the initialization is `admin` and the password will be asked by `trytond-admin`.

---

<div class="post-metadata">

### Author: ![alex](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://discuss.tryton.org/u/alex)
#### Post date: [August 24, 2018, 9:54pm UTC](https://discuss.tryton.org/t/sqlite-database/675/5 "2018-08-24T21:54:26Z")

</div>

Somehow I manage to make a big mess out of this.

I

- installed postgresql, created a user with the power to create databases, created database ‘testdb’
- changed /etc/tryton/trytond.conf → [database] uri = postgresql://‘user-from-above’:‘according-password’@localhost/
- started trytond from console (as normal user)
- in a new console issued ‘trytond-admin -c /etc/tryton/trytond.conf -d testdb --all’ to initialize database

BUT: I get another traceback with final error:  
‘OSError: Database “testdb.sqlite” doesn’t exist!’

This seems strange to me. Why is trytond-admin trying to access an sqlite-database here?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 24, 2018, 10:50pm UTC](https://discuss.tryton.org/t/sqlite-database/675/6 "2018-08-24T22:50:19Z")

</div>

Are you sure that the configuration file is readable by the user running `trytond-admin`?  
Otherwise please provide the full output of the command.

---

<div class="post-metadata">

### Author: ![alex](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://discuss.tryton.org/u/alex)
#### Post date: [August 25, 2018, 9:05am UTC](https://discuss.tryton.org/t/sqlite-database/675/7 "2018-08-25T09:05:16Z")

</div>

Ah, indeed. trytond.conf wasn’t readable by my user. After adding myself to the ‘tryton’ group setting up a database works now.

Thank you!

---

<div class="post-metadata">

### Author: ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)
#### Post date: [August 26, 2018, 11:48am UTC](https://discuss.tryton.org/t/sqlite-database/675/8 "2018-08-26T11:48:31Z")

</div>

I think we should consider giving appropriate error messages. If the configuration file is not found or readable I think trytond should not start, instead of starting with some default values.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 26, 2018, 12:28pm UTC](https://discuss.tryton.org/t/sqlite-database/675/9 "2018-08-26T12:28:17Z")

</div>

We follow standard [Python library on this](https://docs.python.org/3.5/library/configparser.html#configparser.ConfigParser.read) and I think they are right.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 26, 2018, 12:29pm UTC](https://discuss.tryton.org/t/sqlite-database/675/10 "2018-08-26T12:29:48Z")

</div>

And more over we inform about the [files really used](http://hg.tryton.org/trytond/file/cc5aba3b12c7/trytond/config.py#l88).

---

<div class="post-metadata">

### Author: ![alex](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://discuss.tryton.org/u/alex)
#### Post date: [August 27, 2018, 6:05am UTC](https://discuss.tryton.org/t/sqlite-database/675/11 "2018-08-27T06:05:57Z")

</div>

In my case trytond didn’t notify me of failing to access the configuration file, I think. At least, I haven’t found any notice, even after enabling verbose output.

Maybe it would be a good idea to print any such message to stderr ? It would have helped me greatly!

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 28, 2018, 8:29am UTC](https://discuss.tryton.org/t/sqlite-database/675/12 "2018-08-28T08:29:30Z")

</div>

It would have if you run it in verbose mode.

---

<div class="post-metadata">

### Author: ![alex](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alex](https://discuss.tryton.org/u/alex)
#### Post date: [August 28, 2018, 9:46am UTC](https://discuss.tryton.org/t/sqlite-database/675/13 "2018-08-28T09:46:55Z")

</div>

Maybe I’m mistaken here, but it seems I don’t get any warnings, even when enabling verbose output.

What I try:

- kill trytond
- remove /etc/tryton/trytond.conf
- invoking trytond with: ‘trytond -v -c /ect/tryton/trytond.conf’

While I do get some output, the only message related to trytond.conf is:

```
20715 140622628394816 [2018-08-28 09:41:16,693] INFO trytond.config using as configuration files

```

This output is obtained regardless if trytond.conf is available or not. Of course it’s possible I overlook something here, but I don’t see any message I would interpret as ‘no configuration file found’…

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 11, 2018, 7:06am UTC](https://discuss.tryton.org/t/sqlite-database/675/14 "2018-09-11T07:06:00Z")

</div>

I submitted [Log when not all configuration are loaded (#7690) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue7690)

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [October 11, 2018, 7:06am UTC](https://discuss.tryton.org/t/sqlite-database/675/15 "2018-10-11T07:06:08Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
