Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9283979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:46:18+00:00 2026-06-18T18:46:18+00:00

I use the following code to make a booking in a system yet it

  • 0

I use the following code to make a booking in a system yet it returns an error:

conn = sqlite3.connect('SADS.db')
cur = conn.cursor()
choice = raw_input("What day would you like to book seats on? F/S : ")
if choice == "F":
    bookseats = [0,1]
    print"What seats would you like to book?"
    bookseats[0] = raw_input("Choice : ")
    bookseats[1] = raw_input("What is their user ID? : ")
    cur.execute("SELECT * FROM seats WHERE Booked='N'")
    rows = cur.fetchone()
    for row in rows:
        if row == None:
            break
        elif row[1] == bookseats[0] and row[4] == "N" and row[3] == "F":
            print "Seat Number:" , row[1] ,"Is now booked!"
            cur.execute("UPDATE seats SET Booked =N AND CustID=?", (bookseats[0]))

Error:

TypeError: 'float' object has no attribute '__getitem__'

I am really confused what the error is and how I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:46:19+00:00Added an answer on June 18, 2026 at 6:46 pm

    You are looping over the result of rows = cur.fetchone(), which retrieves just one row. Remove that line and just loop directly over the cursor:

    cur.execute("SELECT * FROM seats WHERE Booked='N'")
    for row in cur:
    

    You do not need to test for row == None either, nor do you need to test if the Booked column is equal to N. Simplify the loop to:

    cur.execute("SELECT * FROM seats WHERE Booked='N' AND CustID=?", (bookseats[0],))
    row = cur.fetchone()
    if row is not None and row[3] == "F":
        print "Seat Number:" , row[1] ,"Is now booked!"
        cur.execute("UPDATE seats SET Booked =N AND CustID=?", (bookseats[0]))
    

    You can just ask the database for rows that match your bookseats[0] column, and where the 3rd column is set to F. You didn’t show us your schema so it is hard to recommend how you can update your query for that.

    Your UPDATE query is incorrect, you probably meant:

    cur.execute("UPDATE seats SET Booked='Y' WHERE CustID=?", (bookseats[0],))
    

    instead.

    Your SQL query and update look suspect though; without knowing the full schema it does look as if you are mixing your seat number and customer number in places.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the following code to make an image fadeOut and, only
I use following code: Create a retry policy, when error, retry after 1 second,
I use the following code to make fixed row headers in my UIScrollView descendant.
Im trying to use the following code to eventually make a game. The code,
I use the following code to make sure I go back to a particular
I added the following code to make use of appearance on newer versions of
I tried to use the following code to make my ImageButton invisible, but clicking
I use the following code to make Propel 1.4 works in a php file.
I use the following code to make cc preserve the existing indentation when the
I have a problem with httpwebrequest exception. I use the following code to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.