database initialization

54 views
Skip to first unread message

Cato Nano

unread,
Jan 31, 2018, 8:34:50 AM1/31/18
to tryton
I run this line

trytond-admin -c ./trytond.conf -d tryton --all

Then I try to start Proteus like this

config = config.set_trytond(database='postgresql://tryton@/')

because I'd like to prod my methods with the same database tha I use when I' m in the client

But this is what I get

---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-8-c8456c787960> in <module>()
----> 1 config = config.set_trytond(database='postgresql://tryton@/')

~/tributi/env/lib/python3.6/site-packages/proteus/config.py in set_trytond(database, user, config_file)
272 config_file=None):
273 'Set trytond package as backend'
--> 274 _CONFIG.current = TrytondConfig(database, user, config_file=config_file)
275 return _CONFIG.current
276

~/tributi/env/lib/python3.6/site-packages/proteus/config.py in __init__(self, database, user, config_file)
219 database_name = uri.path.strip('/')
220 if not database_name:
--> 221 database_name = os.environ['DB_NAME']
222 self.database_name = database_name
223 self._user = user

~/tributi/env/lib64/python3.6/os.py in __getitem__(self, key)
667 except KeyError:
668 # raise KeyError with the original key value
--> 669 raise KeyError(key) from None
670 return self.decodevalue(value)
671

KeyError: 'DB_NAME'


I thought I passed the db URI as an argument. Why does the db name get searched as a n env var ?

How can I use Proteus with the same Postgres db that I use in the client rather than a sqlite one ?

Thanks

Sergi Almacellas Abellana

unread,
Jan 31, 2018, 8:38:19 AM1/31/18
to try...@googlegroups.com
El 31/01/18 a les 14:34, Cato Nano ha escrit:
The uri you passed has no database name. The URI format is:

postgresql://user:password@host/database (all arguments are optional)

Proteus search for an environment variable called DB_NAME if no database
name is passed on the uri. You don't have this environment variable set.

So you have two options here:

1. Set DB_NAME environament variable with the database name to use.
2. Include the database name in the uri.

Hope it helps.

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Cato Nano

unread,
Jan 31, 2018, 12:08:42 PM1/31/18
to tryton
thank you Sergi

my undertsanding of this is that with that connection string, the connection to postgres happens through some Unix socket, rather than a loopback tcp connection

That string is the one that's in my trytond.conf file and it works.

As a reference, you can see this answer, in which they suggest that you can omit the host when using a unix socket

https://stackoverflow.com/questions/27037990/connecting-to-postgres-via-database-url-and-unix-socket-in-rails

In order to debug I could use a loopback tcp thing, speed won' t be a concern in that case

it' s just that I' d love to feel like I have a grip on these issues

Cato Nano

unread,
Jan 31, 2018, 12:10:14 PM1/31/18
to tryton

more precisely, this is the string that is in my conf file

uri = postgresql://tryton@/

Message has been deleted

Cato Nano

unread,
Feb 1, 2018, 4:41:22 AM2/1/18
to tryton
Il giorno mercoledì 31 gennaio 2018 18:10:14 UTC+1, Cato Nano ha scritto:
> more precisely, this is the string that is in my conf file
>
> uri = postgresql://tryton@/

ok I configured postgres in a liberl way and I managed to find an uri string that works with proteus

I' d still love to be able to avoid using tcp connections, but that's a detail

Thanks
Reply all
Reply to author
Forward
0 new messages