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)
|
dbapi = Sqlite(path_to_db)
|
||||||
else:
|
else:
|
||||||
# NOTE: you can override these settings here or in settings.ini:
|
# NOTE: you can override these settings here or in settings.ini:
|
||||||
dbname = config.get('database.dbname')
|
dbkwargs = {}
|
||||||
host = config.get('database.host')
|
for key in config.get_section_settings('database'):
|
||||||
user = config.get('database.user')
|
# Use all parameters except dbtype as keyword arguments
|
||||||
password = config.get('database.password')
|
if key == 'dbtype':
|
||||||
port = config.get('database.port')
|
continue
|
||||||
|
dbkwargs[key] = config.get('database.' + key)
|
||||||
if dbtype == "postgresql":
|
if dbtype == "postgresql":
|
||||||
from gramps.plugins.db.dbapi.postgresql import Postgresql
|
from gramps.plugins.db.dbapi.postgresql import Postgresql
|
||||||
dbapi = Postgresql(dbname=dbname, user=user,
|
dbapi = Postgresql(**dbkwargs)
|
||||||
host=host, password=password)
|
|
||||||
else:
|
else:
|
||||||
raise AttributeError(("invalid DB-API dbtype: '%s'. " +
|
raise AttributeError(("invalid DB-API dbtype: '%s'. " +
|
||||||
"Should be 'sqlite' or 'postgresql'") % dbtype)
|
"Should be 'sqlite' or 'postgresql'") % dbtype)
|
||||||
|
Loading…
Reference in New Issue
Block a user