Question: I keep getting a cur.execute ( classes _ table ) sqlite 3 . OperationalError: incomplete input my student table works when i run it

I keep getting a " cur.execute(classes_table)
sqlite3.OperationalError: incomplete input"
my student table works when i run it without the classes table so i dont know what is wrong. (pretty new to all this)
import sqlite3 as sql
Database_Content =[
{
"id": 0,
"currentlyEnrolled": False,
"age": 21,
"firstName": "Veronica",
"lastName": "Potter",
"gender": "female",
"email": "veronicapotter@furnigeer.com",
"phone": "+1(849)512-2231",
"address": "771 Downing Street, Tyro, Nebraska, 6696",
"registered": "Wed Feb 19202007:25:47",
'classes': "0,2,14,9"
},
{
"id": 1,
"currentlyEnrolled": True,
"age": 25,
"firstName": "Bray",
"lastName": "Summers",
"gender": "male",
"email": "braysummers@furnigeer.com",
"phone": "+1(833)417-2236",
"address": "184 Dekoven Court, Driftwood, Marshall Islands, 6520",
"registered": "Mon Aug 06201804:13:31",
"classes": "1,9,4,14"
}
]
Classes =[
{
"id": 0,
"code": "INFO 1003",
"title": "Basic Programming",
"description": "Basic programming class using Python."
},
{
"id": 1,
"code": "INFO 1001",
"title": "Intro to Programming",
"description": "Visual programming class"
},
{
"id": 2,
"code": "INFO 1002",
"title": "Intro to Web Development",
"description": "Basics of HTML and CSS"
}
]
conn = sql.connect('main.db')
cur = conn.cursor()
student_table =('CREATE TABLE IF NOT EXISTS students (id INTEGER not null primary key, '
' currentlyEnrolled TEXT not null, age INTEGER not null, firstName VARCHAR(30),'
' lastName VARCHAR(30), gender VARCHAR(7), email VARCHAR(40), phone VARCHAR(11),'
' address TEXT not null, registered VARCHAR, classes INTEGER)')
cur.execute(student_table)
for x in Database_Content:
cur.execute('''INSERT INTO students (id, currentlyEnrolled, age, firstName, lastName,
gender, email, phone, address, registered, classes) VALUES (?,?,?,?,?,?,?,?,?,?,?)''',
(x['id'], x['currentlyEnrolled'], x['age'], x['firstName'], x['lastName'],
x['gender'], x['email'], x['phone'], x['address'], x['registered'], x['classes']))
classes_table =('CREATE TABLE IF NOT EXISTS classes (id INTEGER not null primary key, '
'code VARCHAR(30), title VARCHAR(100), description VARCHAR(100)')
cur.execute(classes_table)
for i in Classes:
cur.execute('''INSERT INTO classes (id, code, title, description) VALUES (?,?,?,?)''',
(i['id'], i['code'], i['title'], i['description']))
print(cur.execute('SELECT * from students').fetchall())
print(cur.execute('SELECT * from classes').fetchall())
conn.commit()
conn.close()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!