Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exception printed twice
#1
Hi,

I'm a little bit confused as the following code prints the exception provoked by the wrong password twice. Does anybody know why?

#!/usr/bin/python3

import pymssql, psycopg2
import psycopg2.extras
import sys

psqluser = "<USERNAME>"
psqlpassword = "<WRONG-PASSWORD>"
psqlserver = "<IP-ADRESSE>"
psqldatabase = "<DATABASE>"

try:
    psqlconn = psycopg2.connect(dbname=psqldatabase, user=psqluser, password=psqlpassword, host=psqlserver)
except Exception as err:
    print(err)
    exit(1)
Thanks
Richard
Reply
#2
Can you post the exact complete error message?
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
I get only one Exception.

With your code, running on Python 3.12.5:
[deadeye@nexus ~]$ python test.py 
could not translate host name "<IP-ADRESSE>" to address: Name or service not known

[deadeye@nexus ~]$ 
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 1,375 Feb-02-2024, 06:06 PM
Last Post: tester_V
  How can histogram bins be separated and reduce number of labels printed on x-axis? cadena 1 1,852 Sep-07-2022, 09:47 AM
Last Post: Larz60+
  Reverse printed words hindubiceps 7 4,213 Apr-21-2020, 05:19 PM
Last Post: deanhystad
  I get "None" at the end of my printed result. dyshkant 3 3,587 Sep-06-2019, 06:31 PM
Last Post: dyshkant
  bytes not being printed as expected Skaperen 2 3,487 Aug-27-2019, 05:33 AM
Last Post: Skaperen
  Change linenumber and filename printed in exceptions like #line in C kryptomatrix 2 3,456 Jul-12-2019, 06:01 AM
Last Post: Gribouillis
  Putting an array for each string that is printed to a loop ClaudioSimonetti 1 2,921 Feb-05-2019, 12:52 PM
Last Post: perfringo
  During handling of the above exception, another exception occurred Skaperen 7 30,289 Dec-21-2018, 10:58 AM
Last Post: Gribouillis
  Why A will be printed twice in the picture Shen 3 4,917 Jul-25-2018, 01:16 PM
Last Post: stranac
  0 error but Not printed Piqurs 5 5,058 Jul-14-2018, 04:43 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020