Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am having trouble getting the execute many function to take in any new items I keep getting not enough keybindings error or not the
I am having trouble getting the execute many function to take in any new items I keep getting not enough keybindings error or not the right type.
how would I enter some test data so it would be executed by my save_data function?
item_data = ( item("school.name"], item("school.city"], item("school.state"], item("2017. student.size"], item("2018.student.size"], item["2016.repayment.3_yr_repayment.overall"], item["2017. earnings.3_yrs_after_completion.overall_count_over_poverty_line"], item("2016.repayment.repayment_cohort.3_year_declining_balance"] ) total_fetch_result += 1 all_data.append(item_data) print("fetched items: ", total_fetch_result) return all_data #create tables - may not need all_data def add_to_database (all_data): c = conn.cursor C.execute('DROP TABLE IF EXISTS school_data;''') C.execute(''CREATE TABLE IF NOT EXISTS school_data ( school_name text, school_city text, school_state text, student_size_2017 real, student_size_2018 real, earnings_3_yrs_after_completion_overall count_over_poverty_line_2017 real, repayment_3_yr_repayment_overall_2016 real, repayment_repayment_cohort_3_year_declining_balance_2016 real A ) def save_data(all_data): c = conn.cursor() C.executemany('INSERT INTO school_data VALUES (?,?,?,?,?,?,?,?)', all_data) conn.commit() Pimport sqlite3 import APImain def test_add_school(): conn = sqlite3.connect("data1.db") c = conn.cursor() APImain.get_data() C.execute(''CREATE TABLE IF NOT EXISTS school_data ( school_name text, school_city text, student_size_2017 real, student_size_2018 real, earnings_3_yrs_after_completion_overall_count_over_poverty_line_2017 real, repayment_3_yr_repayment_overall_2016 real ) (( test_data = [['sodjn'], ['sdjbcs'], [100], [100], [200], [3000]] for i in range(len(test_data)): test_data.append([(str(i + 1)))) += 1 APImain.save_data(test_data) O # c.execute((f'INSERT INTO school_data (school_name, school_city, student_size_2017, student_size_2018, # earnings_3_yrs_after_completion_overall_count_over_poverty_line_2017, repayment_3_yr_repayment_overall_2016) # VALUES ('BSU', 'Braintree', 1, 2, 3, 4) conn.commit() conn = sqlite3.connect("data1.db") C = conn.cursor() C.execute(''SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'University_%;"") c.fetchall D10Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started