I want to connect to the Postgresql database using Python in Windows. This is the function I have written:
def config(filename='', section='postgresql'):
# create a parser
parser = ConfigParser()
# read config file
parser.read(filename)
# get section, default to postgresql
db = {}
if parser.has_section(section):
params = parser.items(section)
for param in params:
db[param[0]] = param[1]
else:
raise Exception('section {0} not found in the {1} file'.format(section, filename))
return db
I have read that I should put "database.ini" in front of "filename". However, it gives me the following message:
section postgresql not found in the database.ini file
Where should I find the "database.ini" in Windows?
database.ini
coming from? I see nothing in this code that will result in a connection. What is the purpose of this code? – Adrian Klaver