0

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"
1
  • Use indentation rather than backticks for blocks of code. I'd change it but it's too small an edit to be allowed. Commented Jan 9, 2015 at 9:51

2 Answers 2

1

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().

Sign up to request clarification or add additional context in comments.

3 Comments

it worked but the value of username and email is similar to 0x0316... how do i convert it to the actual string behind this value? tried using fetchone() and fetchall() but i get that sqlite.connection has no attribute for this
You need to get a cursor (cur = self.conn.cursor()) and call both execute and fetchone on that, rather than directly on the connection object.
tried but the return value of each variable is None
0

Try adding quotes to username:

UsernameE  = self.conn.execute("SELECT rowid,* FROM tblPlayers WHERE p_Username = '" + username + "'") 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.