Check if a record exists
Hello!
I am writing a python function to check if a user exists in a database. This is the code:
def searchUser():
print 'Which user are you looking for?'
Username = raw_input('> ')
sql = '''IF EXISTS (SELECT * FROM Users WHERE Username = %s)
PRINT 'User exist'
ELSE
PRINT 'User does not exist'''
cursor.execute(sql, (Username))
result = cursor.fetchall()
However, when I run it it returns a syntax error. Can anyone help me to write it properly?
Cheers!
Dani
Subject
Written By
Posted
Check if a record exists
July 22, 2010 06:09AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.