[Python] Python MySQL Connector script in VS Code runs but shows no output in terminal

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    I’m trying to run this Python script in VS Code:

    import mysql.connector

    try:
    # Try to connect
    conn = mysql.connector.connect(
    host="localhost",
    user="root",
    password="1234",
    database="lmsdb1"
    )
    print("✅ Connection successfully created!")

    except mysql.connector.Error as err:
    print(f"❌ Connection failed: {err}")

    finally:
    # Close connection if it was established
    try:
    if conn.is_connected():
    conn.close()
    print("✅ Connection closed.")
    except:
    pass


    But no output appears in the terminal (no print statements at all).

    My setup:


    • Windows 11


    • Python 3.13


    • VS Code latest version


    • Running with “Run Python File” button

    Tried:


    1. Running in terminal with python DBCon.py


    2. Restarted VS Code


    3. Reinstalled Python extension

    Still no output. Is this a VS Code config issue or something in my code?

    Output I'm expecting is:

    Connecting successfully created


    But instead I'm getting no output

    Continue reading...

Compartilhe esta Página