Sqlite3 error in Project, HELP!

Hello! I am currently working on the hotel database project in the advance python3 class.


I’m running this code and I get an error that states:

Traceback (most recent call last):
File “script.py”, line 40, in
curs.executemany(’’‘INSERT INTO bra_customers VALUES (?,?,?,?,?,?,?,?,?,?,?,?)’’’, bra)
sqlite3.ProgrammingError: Recursive use of cursors not allowed.

Import module

import sqlite3

Task 1: Create connection object

con = sqlite3.connect(‘hotel_booking.db’)

Task 2: Create cursor object

curs = con.cursor()

Task 3: View first row of booking_summary

#print(curs.execute(’’‘SELECT * FROM booking_summary’’’).fetchone())

Task 4: View first ten rows of booking_summary

#print(curs.execute(’’‘SELECT * FROM booking_summary’’’).fetchmany(10))

Task 5: Create object bra and print first 5 rows to view data

bra = (curs.execute(’’‘SELECT * FROM booking_summary WHERE country = ‘BRA’;’’’))


Task 6: Create new table called bra_customers

hotel TEXT,
is_cancelled INTEGER,
lead_time INTEGER,
arrival_date_year INTEGER,
arrival_date_month TEXT,
arrival_date_day_of_month INTEGER,
adults INTEGER,
children INTEGER,
country TEXT,
adr REAL,
special_requests INTEGER

Task 7: Insert the object bra into the table bra_customers

curs.executemany(’’‘INSERT INTO bra_customers VALUES (?,?,?,?,?,?,?,?,?,?,?,?)’’’, bra)

Nevermind! I figured it out.

bra_list = bra.fetchall()

I added this line, I guess you needed to have a fetch method to get the actual tuple of values to add into the new table.

Revisiting this topic again, the above edit i stated did not fix the issue, it seems the DB entry I put doesn’t get saved at all because printing out bra_customers yields an empty list.

Went back to the section lessons that covered this, doesn’t seem to have an answer as none of the materials mentioned this issue. The code I used was what they are telling me to use in the hint section well!

How do I get rid of the recursive use error?