Я сделал здесь python программу и хотел отправить код своему другу, и он не смог добавить значения через программу в мою базу данных, есть ли способ, которым я могу разрешить его доступ.
Код:
from tkinter import *
import mysql.connector as mysql
root = Tk()
def flush(*args):
name = nme.get()
phone = ph.get()
emirate = e_id.get()
con = mysql.connect(host='127.0.0.1', user='root', password='monkey123', database='NZ')
c = con.cursor()
c.execute("Insert into gliy VALUES ('"+name+"','"+str(phone)+"','"+str(emirate)+"')")
c.execute('commit')
con.close()
e_1.delete(0, END)
e_2.delete(0, END)
e_3.delete(0, END)
nme= StringVar()
ph = IntVar()
e_id = IntVar()
label_1 = Label(root,text='Patient Name',fg='blue')
label_2 = Label(root,text='Phone number',fg='blue')
label_3 = Label(root,text='Emirates ID',fg='blue')
label_1.grid(row=0,column=0)
label_2.grid(row=1,column=0)
label_3.grid(row=2,column=0)
e_1 = Entry(root,borderwidth=2,textvariable=nme)
e_2 = Entry(root,borderwidth=2,textvariable=ph)
e_3 = Entry(root,borderwidth=2,textvariable=e_id)
e_1.grid(row=0,column=1,ipady=10,padx=10,pady=10)
e_2.grid(row=1,column=1,ipady=10,padx=10,pady=10)
e_3.grid(row=2,column=1,ipady=10,padx=10,pady=10)
B_1 = Button(root,text='ENTER',command =flush)
B_1.grid(row=4,column=1)
root.mainloop()
ОШИБКА:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\network.py", line 509, in open_connection
self.sock.connect(sockaddr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in _call_
return self.func(*args)
File "C:/Users/97513/AppData/Local/Programs/Python/Python38-32/new.py", line 14, in flush
con = mysql.connect(host='127.0.0.1', user='root', password='monkey123', database='NZ')
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\connection.py", line 95, in _init_
self.connect(**kwargs)
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\abstracts.py", line 716, in connect
self._open_connection()
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\connection.py", line 206, in _open_connection
self._socket.open_connection()
File "C:\Users\97513\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mysql\connector\network.py", line 511, in open_connection
raise errors.InterfaceError(
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (10061 No connection could be made because the target machine actively refused it)