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 8967083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:10:05+00:00 2026-06-15T17:10:05+00:00

I’m working on a program that is able to make quizzes by exporting questions

  • 0

I’m working on a program that is able to make quizzes by exporting questions into a database. I’ve looked on the internet for a bit and it said that one of the easiest ways to import or export to a database in python is to use the SQLite3 plugin, so I’m trying it out.This is the first time I’ve used the SQLite3 plugin with python, and I keep getting a syntax error on the self.connection.commit() in:

def AddQuestion(self, Question, Answer1, Answer2, Answer3, Answer4):
    self.cursor.execute("""INSERT INTO questions
                            VALUES (?, ?, ?, ?, ?, ?)""", (None, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer)
    self.connection.commit()

If I were to turn it into a comment by adding # before it, it would tell me that the print in this was a syntax error:

print ("Would you like to make a test? Or would you like to take a test?")

Maybe its my indentation, or am I doing something wrong?

import squlite3
class QuestionStorage(object):
    def _init_(self, path):
        self.connection = sqlite3.connect(path)
        self.cursor = self.connection.cursor ()

def Close(self):
    self.cursor.close()
    self.connection.close()

def CreateDb(self):
    query = """CREATE TABLE questions
             (id INTEGER PRIMARY KEY, Question TEXT, Answer1 TEXT, Answer2 TEXT, Answer3 TEXT, Answer4 TEXT, CorrectAnswer TEXT)"""
    self.cursor.exeute(query)
    self.connection.commit()
    #self.cursor.close()

def AddQuestion(self, Question, Answer1, Answer2, Answer3, Answer4):
    self.cursor.execute("""INSERT INTO questions
                            VALUES (?, ?, ?, ?, ?, ?)""", (None, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer)
    self.connection.commit()

def GetQuestion(self, index = None):
    self.cursor.execute("""SELECT * FROM questions WEHRE id=?""", (index,))



print ("Would you like to make a test? Or would you like to take a test?")
testTaker = input ("To create a test, type Create. To take a test, type Take.")

if testTaker == "Create":
    testName = input ("Give your test a name.")
    testQ = int(input ("How many questions will be on this test? (Numeric value only.)"))
    testType = input ("Will this test be multiple choice? (y/n)")
    if testType == "N" or "n":
        counter = 1
        qs = QuestionStorage("questions.db")
        qs.CreateDb()
        counter = 1
        while counter >= testQ:
            Answer = []
            Question = input ("What is your question?")
            Answer[1] = input ("What is the first answer?")
            Answer[2] = input ("What is the second answer?")
            Answer[3] = input ("What is the third answer?")
            Answer[4] = input ("What is your last answer?")
            correctAnswer = input("Which answer is the correct answer? (1, 2, 3, or 4?)")
            Answer[5] = Answer[correctAnswer]

        qs.AddQuestion(Question, Answer[1] , Answer[2], Answer[3], Answer[4], Answer[5])
        counter +=1


else:

and then after the else, I’d have the code for reading the database to take a test.

If anyone can help me out with this, that would be great. Right now I’m just trying to get it to the point where I can run it in debug.

  • 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-15T17:10:07+00:00Added an answer on June 15, 2026 at 5:10 pm

    You forgot to close the parentheses here:

    self.cursor.execute("""INSERT INTO questions
                            VALUES (?, ?, ?, ?, ?, ?)""", (None, Question, Answer1, Answer2, Answer3, Answer4, CorrectAnswer)
    

    Put another closing ) at the end of the line.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y’all
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

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.