Python and SQLite, problems with my database

The problem is that I work very recently in Python and SQLite, who recommended it to me because it is very easy to work with them together.
I happen to be creating a database to enroll students in different courses. The problem occurred when I arrived at the part where I wish to consult my database. If a student is already registered, let me do it. the query, but if it is new, let me add it and save it in the database.

Here is what I prepared:

from tkinter import *
from tkinter import messagebox
tkinter import ttk
import sqlite3

window = Tk ()

window.title (& # 39; ------- Administrators ------- & # 39;)
window.geometry (& # 39; 350x150 + 500 + 250 & # 39;)
Label (window, text = "User:"). Pack ()
box1 = Entry (window)
box1.pack ()

Label (window, text = "Password:"). Pack ()
box2 = Entry (window, show = "*")
box2.pack ()

def login ():
# Connect to the database
db = sqlite3.connect (C:  sqlite  gui  GDK & # 39;)
c = db.cursor ()

user = box1.get ()
contr = box2.get ()

c.execute ('SELECT * FROM Administrators WHERE User =? AND Password =?', (user, contr))

if c.fetchall ():
window.withdraw ()
window2 = Tk ()
window2.title (& # 39; ------- Cursing ------- & # 39;)
window2.geometry (350x150 + 500 + 250 & # 39;)

Button2 = ttk.Button (window2, text = "Existing", command = open ("C:  sqlite  gui  GDK"))
Button2.pack ()

Button3 = ttk.Button (window2, text = "New", command = open (& # 39; C:  sqlite  gui  GDK & # 39;))
Button3.pack ()

if Button2 is true:
window2.withdraw ()
window3 = Tk ()
window3.title (& # 39; ------- Existing ------- & # 39;)
window3.geometry (& # 39; 350x150 + 500 + 250 & # 39;)

Label (window3, text = "DNI:"). Pack ()
box3 = Entry (window3)
box3.pack ()
def dni ():
# Connect to the database
db = sqlite3.connect (C:  sqlite  gui  GDK & # 39;)
c = db.cursor
c.execute ('SELECT * FROM Cursor WHERE DNI =?', (DNI))
DNI = caja3.get ()
Button2 = ttk.Button (text = "existing", command = dni) .pack ()
window3.mainloop ()

if Button3 is true:
window4 = Tk ()
window4.title (& # 39; ------- New ------- & # 39;)
window4.geometry (350x150 + 500 + 250 & # 39;)
Label (window4, text = "DNI:"). Pack ()
box4 = Entry (window4)
box4.pack ()

Label (window4, text = "Name:"). Pack ()
box5 = Entry (window4)
box5.pack ()

Label (window4, text = "Name:"). Pack ()
box6 = Entry (window4)
box6.pack ()

Label (window4, text = "Email:"). Pack ()
box7 = Entry (window4)
box7.pack ()

Label (window4, text = "Phone:"). Pack ()
box8 = Entry (window4)
box8.pack ()

Label (window4, text = "Institution_representada:"). Pack ()
box9 = Entry (window4)
box9.pack ()

def New ():
# Connect to the database
db = sqlite3.connect (C:  sqlite  gui  GDK & # 39;)
c = db.cursor ()

DNI = caja4.get ()
Last name = box5.get ()
Name = box6.get ()
Email = caja7.get ()
Phone = box8.get ()
Institutionrepresented = caja9.get ()
if not:
messagebox.showerror (title = (& # 39; incorrect login & # 39;), message = (& # 39; username or password incorrect))

c.close ()
Button1 = ttk.Button (text = "Login", command = login) .pack ()


window.mainloop ()

The problem is that I do not know what command to use to make me a request: /, "open" will not let me, if someone can give me an answer or want to contact me please be of great help!

greetings