Python Forum
Virtual Env changing mysql connection string in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Virtual Env changing mysql connection string in python
#1
I have a script that uses a Virtual Environment and has a connection to mysql where the connection string has the host as localhost or 127.0.0.1, it works without the virtual environment, however, when i run it in the venv, it changes the host to 172.18.0.1, why does that happen?

with mysql.connector.connect(**mysql_webserver_connection, charset="utf8") as conn:
        with conn.cursor(dictionary=True) as cursor:
            cursor.execute(query_string)
            results = cursor.fetchall()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to change connection and queries from SQLite to MySQL Bxapocalypse1 2 1,299 Oct-20-2025, 11:35 PM
Last Post: Pedroski55
  Venv - Python Virtual Environment on Raspberry Pi DanneA 4 1,869 Jul-02-2025, 05:41 PM
Last Post: Larz60+
  Python automation: Sending clicks/keys to VMware virtual machine from host olips784 0 1,327 May-18-2025, 06:28 PM
Last Post: olips784
  Python use of virtual environments bre67e49 4 1,790 Feb-19-2025, 04:01 AM
Last Post: Sece1967
  question about changing the string value of a list element jacksfrustration 4 3,127 Feb-08-2025, 07:43 AM
Last Post: jacksfrustration
  I cannot create a virtual environment on visual studio code using python Willem_Aucamp316 2 13,073 Nov-27-2024, 02:20 PM
Last Post: menator01
  Issues with MySql Connection EMG2024 2 1,699 May-29-2024, 03:11 PM
Last Post: EMG2024
  I don't know what is wrong (Python and SQL connection) shereen 3 2,359 Apr-01-2024, 08:56 AM
Last Post: Pedroski55
  No Internet connection when running a Python script basil_555 8 5,240 Mar-11-2024, 11:02 AM
Last Post: snippsat
  Best practice on using virtual environments in Python bytecrunch 6 33,653 Feb-14-2024, 03:22 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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