Reputation: 93
I have a problem, i am trying to do a validation between a username to that username email by compairing the rowid in python and SQLite, here is the code:
username = self.txtUsername.GetValue()
email = self.txtEmail.GetValue()
UsernameE = self.conn.execute("SELECT rowid,* FROM tblPlayers WHERE p_Username="
+ username)
EmailU = self.conn.execute("SELECT rowid,* FROM tblPlayers WHERE p_Email=" + email)
The error is:
> UsernameE = self.conn.execute("SELECT rowid,* FROM tblPlayers WHERE p_Username="
+ username)
sqlite3.OperationalError: no such column: "what i inserted in the username"
Upvotes: 0
Views: 1528
Reputation: 599450
Your SQL is malformed, because you don't close the quote after the username value. But you shouldn't be doing it that way anyway: you should be using a parameter:
self.conn.execute("SELECT rowid,* FROM tblPlayers WHERE p_Username=? ", (username,))
Also note that execute doesn't return the value: you need to fetch it, eg with fetchone()
.
Upvotes: 1
Reputation: 1318
Try adding quotes to username:
UsernameE = self.conn.execute("SELECT rowid,* FROM tblPlayers WHERE p_Username = '" + username + "'")
Upvotes: 0