May-25-2017, 09:18 AM
OK, so i have made some progress, i have managed to get access to my db remotely and i can get values from it, but now i need to assign values from the db to specific values and i cant figure out how to do it., heres what i got:
import mysql.connector from mysql.connector import Error class dbcon: """ Connect to MySQL database """ ip = 0 port = 0 try: print('Trying to establish connection to database...') connection = mysql.connector.connect(host='db.sample.com', database='ipinfo', user='user', password='password') if connection.is_connected(): print('Connection Successful!!!') cursor = connection.cursor() cursor.execute("SELECT ip, port FROM stations") row = cursor.fetchone() while row is not None: print(row) row = cursor.fetchone() """ parse ip from row to variable ip """ """ parse port from row to variable port """ except Error as e: print(e) finally: print("Connection to database closed!") connection.close()Cant figure out how to do this... pls help