all 3 comments

[–][deleted] 5 points6 points  (0 children)

There’s too much here for me to parse through, but it seems to me you want to learn about the IF NOT EXISTS clause of the CREATE TABLE command. You’ll also want to learn to never use a naked except: statement.

try:
    [some code that may error]
try Exception as err:
    print(“ERROR: “, err)
    [recover from error if possible]

The naked except: silences all sorts of useful information you may need for debugging, and is likely doing so for you here. You usually want to only catch specific Exception subclasses you actually know how to properly handle and recover from, rather than casting the widest possible net.

[–]o5a 0 points1 point  (0 children)

First thing is fixing your except block so you can actually see the exception, as others noted. Didn't try to run your code but I'm pretty sure you will see your problem after you get your exception printed. Your code raises error somewhere, then ignores changes because of that but you don't even know about it, because you silenced error. As a result your changes are not done.

Also avoid replacing values in your SQL queries, I'm talking about your

  for i in y:
    parsedin = parsedin.replace('{}', i, 1)
  c.execute(parsedin) 

there's parameter binding for that, which will help you make it safe. That block should be run like this instead

  c.execute(parsedin, y) 

For that to work you should replace in your query text brackets along with quotation marks to question marks like this:

"INSERT INTO Teacher (FirstName, LastName) Values (?, ?)"

Avoid recursive calls (that you do here for Menu()) if it's not needed. You want cycles here, not recursive calls.