Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def interact_database(command):
- connection = psycopg2.connect("dbname=NAME user=NAME password=PASSWORD")
- cursor = connection.cursor()
- cursor.execute(command)
- connection.commit()
- results = None
- try:
- results = cursor.fetchall()
- except psycopg2.ProgrammingError:
- print("Connection failure.")
- pass
- cursor.close()
- connection.close()
- return results
- def pick_question(type):
- if type == 'G':
- QuestionID = random.randint(1,38)
- elif type == 'Gr':
- QuestionID = random.randint(39,60)
- elif type == 'R':
- QuestionID = random.randint(61,89)
- else:
- QuestionID = random.randint(90,119)
- interact_database("SELECT Question FROM Questions WHERE Question_ID = %s")(QuestionID)
- pick_question('G')
- psycopg2.ProgrammingError: syntax error at or near "%"
- LINE 1: SELECT Question FROM Questions WHERE Question_ID = %s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement