I read the new version in django document, I am follow this post , but doesn’t work:
**conn = _connect(dsn, connection_factory=connection_factory, **kwasync)**
django.db.utils.OperationalError: definition of service "Servers" not found
here is my processing:
1.I create the file ".pg_service.conf" in %APPDATA%, and I wrote database information, like this:
[Servers]
host=localhost
user=wingto
dbname=HyCloud
port=5432
2.create passfile in nearby my django project, manage.py
enter image description here
localhost:5432:HyCloud:wingto:*****
3.Setting.py in django
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"OPTIONS": {
"service": "Servers",
"passfile": "passfile",
},
}
}
2
Answers
You have given the wrong file extension your file should start with ‘.passfile’ and it should be inside the project folder. please save your file with ‘.passfile’ don’t use .conf
According to PostgreSQL documentation, it’s suggested to create your
pg_service.conf
andpgpass.conf
inside the%APPDATA%postgresql
like this%APPDATA%postgresql.pg_service.conf
and the password file%APPDATA%postgresqlpgpass.conf
.https://www.postgresql.org/docs/current/libpq-pgservice.html
https://www.postgresql.org/docs/current/libpq-pgpass.html