我从python和sqlite3的Tkinter模块开始。我正在尝试在数据库中添加新列,并在其中使用datetime.datetime.now()
函数插入时间,但是我在名为 Fecha
有什么建议吗?
这是功能:
def database():
username = Username.get()
passw = password.get()
if (passw == 'abc'): #Just trying an output
print("ok")
else :
sector = area.get()
prog = var1.get()
time = datetime.datetime.now()
conn = sqlite3.connect('Nanotechnology.db')
with conn:
cursor=conn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS Student (Username TEXT,Password TEXT,Area TEXT,Programs INT,Fecha TEXT)')
cursor.execute('INSERT INTO Student (Username,Password,Area,Programs,Fecha) VALUES(?,?,?,?,?)',(username,passw,sector,prog,time))
conn.commit()
Label(root, text= "Succesful Registration", fg="green", font =("bold",12)).place(x=180, y=450)
sleep(3)
root.destroy()