And when our Python code tries to execute an INSERT statement that would violate this constraint, Sqlite refuses to apply it and throws an error. We should handle this error proprtly, and instead of crashing the app we should catch it and report to the user something like "error: given user already exists".
If you try to create the same user twice, the app throws this error:
It happens because our table has a constraint saying that usernames must be unique (the
login TEXT unique
part):https://github.com/thermobased/flask-webapp/blob/5ac124c49d5c7c7ab466f4d83daa24ba7dd3d06a/create.sql#L1
And when our Python code tries to execute an INSERT statement that would violate this constraint, Sqlite refuses to apply it and throws an error. We should handle this error proprtly, and instead of crashing the app we should catch it and report to the user something like "error: given user already exists".
Ivan