Reputation: 25
So i'm having a problem here with this snippit of code. The database isnt the problem and is completely populated. Now it is supposed to bring up the console/command line where i can then input the information as required. For example the question in the question database is:
"Over the last two weeks have you have symptoms of the flu?"
Currently this piece of code doesn't produce anything and i'm fairly new to python coding when i changed from a dictionary of questions to then adding them into a database and trying to pull them from the database. I do know the problem is in the first lines of code as running from the dictionary the code has worked previously.
#Question1
conn.execute("SELECT question from question WHERE questionID = '1'")
question1 = conn.fetchone()
# print the question
print (question1())
# use the question 1 choices to get an answer
answer = input(question1.get()).lower()
if answer == question1.get(answer):
c = conn.execute("SELECT illnessID, Illness, illnessinfo from illnesses WHERE illness = 'Flu'")
for row in c:
print( "Illness Identifier = ", row[0])
print( "Suspected Illness= ", row[1])
print( "Displayed Symptom = ", row[2])
print("Thanks this has been recorded.")
ident = ident + " - " + row[1]
c = conn.execute("SELECT drugID, drug from drugs WHERE drug = 'Flu injection'")
for row in c:
print( "Drug = ", row[0])
print( "Drug = ", row[1])
pescr = pescr + " - " + row[1]
print(ident)
print(pescr)
print("\n")
else:
print("Okay Next question.")
c.execute("INSERT OR IGNORE INTO question(questionID, question) VALUES(1,'Over the last two weeks have you have symptoms of the flu?')")
c.execute("INSERT OR IGNORE INTO choices (choicesID, choices) VALUES(1,'Yes')")
c.execute("INSERT OR IGNORE INTO choices (choicesID, choices) VALUES(2,'No')")
c.execute("INSERT OR IGNORE INTO answer (answerID, answer) VALUES(1,'Yes')")
c.execute("INSERT OR IGNORE INTO answer (answerID, answer) VALUES(2,'No')")
Upvotes: 0
Views: 40
Reputation: 52
My guess is print (question1())
should be replaced by print (question1)
question1 should contain a tuple which is not callable.
But that should have given you an error...
Upvotes: 1