Browse Source

Fixes retrieval of vals to int

Jose Reyes 5 years ago
parent
commit
ee1d6ba168
1 changed files with 7 additions and 3 deletions
  1. 7
    3
      app/index.py

+ 7
- 3
app/index.py View File

15
         station_name = request.form['station']
15
         station_name = request.form['station']
16
 
16
 
17
         db = get_db()
17
         db = get_db()
18
-        station_id = db.execute(
18
+        station_query_res = db.execute(
19
             'SELECT s_id FROM station WHERE nombre_empleado=?',
19
             'SELECT s_id FROM station WHERE nombre_empleado=?',
20
             (station_name,)
20
             (station_name,)
21
         ).fetchone()
21
         ).fetchone()
22
+        if station_query_res is not None:
23
+            station_id = station_query_res[0]
22
         db.execute(
24
         db.execute(
23
             'UPDATE station SET last_turn = last_turn + 1 WHERE s_id=?',
25
             'UPDATE station SET last_turn = last_turn + 1 WHERE s_id=?',
24
             (station_id,)
26
             (station_id,)
25
         )
27
         )
26
-        turn = db.execute(
28
+        turn_query_res = db.execute(
27
             'SELECT last_turn FROM station WHERE s_id=?',
29
             'SELECT last_turn FROM station WHERE s_id=?',
28
             (station_id,)
30
             (station_id,)
29
         ).fetchone()
31
         ).fetchone()
32
+        if turn_query_res is not None:
33
+            turn = turn_query_res[0]
30
         db.execute(
34
         db.execute(
31
             'INSERT INTO turno (cName, cEmail, turn, timeArrival, station)'
35
             'INSERT INTO turno (cName, cEmail, turn, timeArrival, station)'
32
-            ' VALUES (?, ?, ?, ?)',
36
+            ' VALUES (?, ?, ?, ?, ?)',
33
             (cName, cEmail, turn, 'testin', station_id)
37
             (cName, cEmail, turn, 'testin', station_id)
34
         )
38
         )
35
         db.commit()
39
         db.commit()