c.execute("update user set email='{}',password='{}'".format(email,password))
看起来就怪怪的……
果然,查阅文档后:
Security Note
Be sure to use question marks when building SQL statements, as done in theexample above. Otherwise, your app will be vulnerable to SQL injection when you use string formatting to build SQL statements.See Using SQLite 3 with Flask for more.
所以说,还是这种方式会安全:
1
2
3
con = get_db()
c = con.cursor()
c.execute("insert or IGNORE INTO user (email,password,level) values (?,?,1)" , [email,password])