0

I have a python app/service that exists within a docker container. I want the python script to be able to access the mysql database running on my local machine without having to bring the database inside the docker. Is it possible to do this?

    while True:
        mydb = mysql.connector.connect(user='root',
                        password='password',
                        host='127.0.0.1',
                        database='data_table',
                        port ='3306')
        requests_queue = []

        mycursor = mydb.cursor()

        mycursor.execute("""
                SELECT username, time_created 
                FROM table
                ORDER BY id DESC LIMIT 1;
                """)

        myresult = mycursor.fetchall()
Sizzler
  • 73
  • 7

0 Answers0