Il giorno mercoledì 31 gennaio 2018 14:38:19 UTC+1, Sergi Almacellas Abellana
ha scritto:
> El 31/01/18 a les 14:34, Cato Nano ha escrit:
> > 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 ?
>
> 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
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
--
You received this message because you are subscribed to the Google Groups
"tryton" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton/dc274b3d-ecae-4d06-8690-438f7994cabf%40googlegroups.com.