franz-see/Robotframework-Database-Library — Issue #19: can't read dbHost and dbPort values from the config file
Author: vparashar
Created: 2012-01-12 16:14:38+00:00
State: open

DatabaseLibrary version = 0.6

connection_manager.py doesn't seem to read the config file's dbHost and dbPort key values properly since it's been defined by default in the function definition for (connect_to_database(...)). It seems like the logical 'or' operator is preventing this because it's stopping to override from config file as soon as it detects a value exists, which it does in the definition.

---
def connect_to_database(self, dbapiModuleName=None, dbName=None, dbUsername=None, dbPassword=None, dbHost='localhost', dbPort="5432", dbConfigFile="./resources/db.cfg"):
...
dbapiModuleName = dbapiModuleName or config.get('default', 'dbapiModuleName')
dbName = dbName or config.get('default', 'dbName')
dbUsername = dbUsername or config.get('default', 'dbUsername')
dbPassword = dbPassword or config.get('default', 'dbPassword')
dbHost = dbHost or config.get('default', 'dbHost') or 'localhost'
dbPort = int(dbPort or config.get('default', 'dbPort'))
---

a quick fix to this can be made by modifying the subject values to 'None' in the definition so...

---
def connect_to_database(self, dbapiModuleName=None, dbName=None, dbUsername=None, dbPassword=None, dbHost=None, dbPort=None, dbConfigFile="./resources/db.cfg"):
---

with that done, ofcourse the user will have to provide these values at the Keyword and Config File.