Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read upload_files from postgres db,but meet the error password authentication failed #12598

Closed
4 tasks done
lovingliferwj opened this issue Jan 10, 2025 · 2 comments
Closed
4 tasks done
Labels
🐞 bug Something isn't working 🤔 cant-reproduce We can not reproduce it or the information is limited

Comments

@lovingliferwj
Copy link

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

the simple code is below, read the db postgres and get the uploadfile information, but meet the password authentication failed.I did not change the username and password in docker-compose.yaml. is this method right?
from sqlalchemy import create_engine,text
username="postgres"
password="difyai123456"
host='0.0.0.0'
port="5432"
dbname="dify"
engine = create_engine(f'postgresql://{username}:{password}@{host}:{port}/{dbname}')
from sqlalchemy.orm import sessionmaker
Session = sessionmaker(autocommit=False,autoflush=False,bind=engine)
session = Session()
session.execute(text("select * from upload_files;"))

test shell :pg_isready -h localhost -p 5432 -U postgres
returns: localhost:5432 - accepting connections

Copy link

dosubot bot commented Jan 10, 2025

Hello, @lovingliferwj! I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve the issue you're facing.

I found a similar unsolved discussion regarding PostgreSQL connection issues in Dify: Unable to connect the postgres database [1].

Regarding your issue, ensure that the PostgreSQL service is correctly configured and running. Here are a few steps to troubleshoot the password authentication failure:

  1. Verify Credentials: Double-check that the username and password in your code match the default settings in the docker-compose.yaml file:

    • Username: postgres
    • Password: difyai123456 [2].
  2. Check Host and Port: Ensure that the host and port in your connection string are correct. Since you are using Docker, the host should typically be localhost or the service name defined in your Docker network, not 0.0.0.0.

  3. Docker Network: If you are running this code outside of the Docker network, ensure that the PostgreSQL port is exposed and accessible from your host machine.

  4. Environment Variables: Make sure there are no environment variables overriding the default credentials.

  5. Database Initialization: Confirm that the database dify exists and is initialized properly.

If these steps do not resolve the issue, consider checking the PostgreSQL logs for more detailed error messages that might provide further insights.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added 🐞 bug Something isn't working 🤔 cant-reproduce We can not reproduce it or the information is limited labels Jan 10, 2025
@crazywoola
Copy link
Member

Please use the right template for bug report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🤔 cant-reproduce We can not reproduce it or the information is limited
Projects
None yet
Development

No branches or pull requests

2 participants