2

I am a newbie at Python and I am trying to insert some data into MySQL. I keep getting an error that I cannot figure out how to fix. I have attempted to import the dns.resolver but I cant find it. The error is stating:

File "C:\Users\Tob\PycharmProjects\cms\window.py", line 3, in import mysql.connector File "C:\Users\Tob\AppData\Local\Programs\Python\Python38\lib\site-packages\mysql\connector_init_.py", line 41, in import dns.resolver ModuleNotFoundError: No module named 'dns'

Here is my code. Any help would be greatly appreciated :)

import tkinter
import mysql
import mysql.connector

top = tkinter.Tk()

def submit():
db = mysql.connector.connect('localhost', 'root', '_______', 'helpdesk')

cursor = db.cursor()

cursor.execute("INSERT INTO users VALUES (:uLogin, :uPassword, :uFirstName, :uLastName, :uEmail)",
{'uLogin': uLogin.get(), 'uPassword': uPassword.get(), 'uFirstName': uFirstName.get(),               'uLastName': uLastName.get(), 'uEmail': uEmail.get()})

cursor.commit()

cursor.close()

submit = tkinter.Button(top, text="Submit", command=submit)
submit.grid(row=5, column=0, columnspan=2, padx=10, pady=10, ipadx=100)
Wondercricket
  • 7,651
  • 2
  • 39
  • 58
Tobin
  • 41
  • 5
  • pip install should have included everything, that is needed, did you get error message when you insztalled it? – nbk Aug 05 '20 at 20:28
  • Are you talking about when I tried to install dns.resolver? – Tobin Aug 05 '20 at 20:40
  • no the mysqlclient, i stalled all your imports in my python and i din't get your message – nbk Aug 05 '20 at 21:01
  • I did not get any error installing from pip mysqlclient. I tried it again and it told me tat "Requirment already satisfied mysqlclient. Is there anything about DNS that I need to install? – Tobin Aug 05 '20 at 21:16
  • i ran your code and it runs, it tells me that you have a lot of bugs, but no dns client iscalled for(python3.8.3 (64 bit) and vs code 1.47 – nbk Aug 05 '20 at 21:26

1 Answers1

3

You should do this in a command line window. (see this question!)

git clone https://github.com/rthalley/dnspython
cd dnspython/
python setup.py install
JarroVGIT
  • 4,291
  • 1
  • 17
  • 29