blob: 25f9003f1cc548dd4a49f87355892576bb5b9786 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
from sqlalchemy.sql import text
class DBQuestion:
def __init__(self, db):
self.db = db
def new(self, question, neg_ans, pos_ans ):
sql = "INSERT \
INTO questions (question, neg_answer, pos_answer) \
VALUES (:question, :neg_answer, :pos_answer) \
RETURNING id ;"
result = self.db.session.execute(
text(sql), {
"question":question,
"neg_answer":neg_ans,
"pos_answer":pos_ans }
)
self.db.session.commit()
return result.fetchone()[0]
|