-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Empty OperationalError when I tried to connect with wrong credentials #1442
Comments
I got exactly the same problem with the same code.
I might have a few elements of comprehension. It might be related to the language of installation for your postgresql database. @luisrojas17 What language are you using for postgresql database ? |
Sorry, I missed this message a few days ago. Out of curiosity, could you try the same operations using psycopg 3? There is some extra care we take there with connection errors and I wonder if they would help in this case too. It is related more to encodings than to language though. What are the encoding, and other parameters, of your database? You can check them with |
i tryed to install psycopg 3 but got : ImportError: no pq wrapper available.
the other parameter of my database are :
-------------+--------------+----------+--------------------+--------------------+----------------------- |
@adikte try Thank you for testing! |
I followed your advice and installed psycopg 3 with the pip install psycopg[binary]. It does work properly which is great, thanks. If i set in my postgresql.conf file the lc_messages variable to 'French_France.1252'" i get : And if set in my postgresql.conf file the lc_messages variable to 'en.US'" i get : @dvarrazzo Any advice on how to correct those problems ? |
@adikte ISTM that you have inconsistent encodings. Connection errors happen before the server had the chance to communicate the client encoding. In psycopg 3.0.8, we use the client encoding found in the connection string, if it is specified (psycopg/psycopg#194), otherwise we fall back on utf8. So, probably, if you add I think the best solution is to create a database with some French+utf8 messages. I don't know how to do it on Windows. |
@dvarrazzo Thank you for quick answer, it is much appreciated. That's great, adding client_encoding=WIN1252 to the connection string work like a charm for psycopg3. |
@adikte I am aware of the problem in psycopg2: will try to address it. Yes, the lack of sqlstate is caused by the error being generated by the libpq rather than the server. |
This is a bug tracker
If you have a question, such has "how do you do X with Python/PostgreSQL/psycopg2" please write to the mailing list or open a question instead.
Please complete the following information:
Describe the bug
When I tried to connect to database with wrong credentials, I did not a descriptive message about the problem.
By the way, some time ago another user reported the same problem (Empty OperationalError on connect #417) but, until now there is not any solution (the issue was closed).
Please let us know:
1: what you did
2: what you expected to happen
3: what happened instead
If possible, provide a script reproducing the issue.
The text was updated successfully, but these errors were encountered: