I would like to check whether the email returned by a query is empty. I am using the following code:
query = "select email from u_code where code = '"+code+"'"
cursor.execute(query)
result_set = cursor.fetchall()
length = cursor.rowcount
if (length==1):
print ' result: ' + str(result_set[0]) + ' OK'
print ' length of result: ' + str(len(result_set[0]))
if (result_set[0] == ''):
print("empty email")
result = 1;
else:
print("email taken")
result = 0
print "result: " + str(result)
The output is wrong. It should return 1 since the email field is empty
result: (u'',) OK
length of result: 1
email taken
result: 0
Any advice?