Use all parameters in settings.ini for postgresql
Read all parameters defined in settings.ini as keyword arguments for postgresql. This also fixes port being ignored.
This commit is contained in:
parent
d611b8b99c
commit
fd2af705e7
@ -38,15 +38,15 @@ if dbtype == "sqlite":
|
||||
dbapi = Sqlite(path_to_db)
|
||||
else:
|
||||
# NOTE: you can override these settings here or in settings.ini:
|
||||
dbname = config.get('database.dbname')
|
||||
host = config.get('database.host')
|
||||
user = config.get('database.user')
|
||||
password = config.get('database.password')
|
||||
port = config.get('database.port')
|
||||
dbkwargs = {}
|
||||
for key in config.get_section_settings('database'):
|
||||
# Use all parameters except dbtype as keyword arguments
|
||||
if key == 'dbtype':
|
||||
continue
|
||||
dbkwargs[key] = config.get('database.' + key)
|
||||
if dbtype == "postgresql":
|
||||
from gramps.plugins.db.dbapi.postgresql import Postgresql
|
||||
dbapi = Postgresql(dbname=dbname, user=user,
|
||||
host=host, password=password)
|
||||
dbapi = Postgresql(**dbkwargs)
|
||||
else:
|
||||
raise AttributeError(("invalid DB-API dbtype: '%s'. " +
|
||||
"Should be 'sqlite' or 'postgresql'") % dbtype)
|
||||
|
Loading…
Reference in New Issue
Block a user