Note that there are some explanatory texts on larger screens.

plurals
  1. POI don't understand why this loop terminates the way it does
    primarykey
    data
    text
    <pre><code>checkSql = 'SELECT userid FROM bs_members WHERE userid = :checkUser' doesUserExist = False while True: doesUserExist = False newUser.userID = ga.getInput('Enter userID: ', "\w+$") checkUserID = ds.execute(checkSql,checkUser=newUser.userID) for row in ds: if row == checkUserID: doesUserExist = True print 'That user name is already in use. Please enter a new username.' break if doesUserExist == False: break else: continue </code></pre> <p>I am using the <code>cx_Oracle</code> module with Python 2.7. I am trying to prompt the user to enter a userID. The program will then check if the userID already exists and if it does prompt the user for a different userID. The execute method is a helper method that uses the execute method from cx_Oracle to interact with the Oracle database. The getInput method prompts the user for input that is then checked against the regular expression.</p> <p>I know I have this wrong but I believe the <code>while</code> loop starts the first action that is taken is the user is prompted for a userID. Then the userID is checked against the database. The <code>for</code> loop starts and checks if the row returned by <code>ds.execute()</code> is the same as the userID provided by the user. If it is the user is told to use another user name and the <code>break</code> exits the <code>for</code> loop. The <code>if</code> statement then checks if a user exists and if it doesn't it breaks the <code>while</code> loop. If not then the <code>while</code> loop iterates so the user is prompted to enter a non-existent userID.</p> <p>What happens is the user is prompted for the userID then none of the checking ever appears to happen to the user and the program moves on to the next piece of code. What am I missing here? I have included a <a href="http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.execute" rel="nofollow">link</a> to the docs for <code>execute()</code>. The execute method in the above code is part of the following helper method:</p> <pre><code>def execute(self, statement, **parameters): if parameters is None: self._curs.execute(statement) else: self._curs.execute(statement,parameters) </code></pre> <p>If I need to provide more information let me know.</p> <p>edit: I forgot the line <code>doesUserExist = False</code> immediately after the beginning of the <code>while</code> loop so I added that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload