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
--
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/be837420-9af6-f89c-1374-e86afe36fde1%40koolpi.com.