Beispiel #1
0
    def sort(cls, new_order):
        cur = get_db().cursor()

        for e in new_order:

            cur.execute("UPDATE %s SET '%s' = ? WHERE id = ?" % (cls.__table_name__, "order"), (e[1], e[0]))
        get_db().commit()
Beispiel #2
0
 def get_max_order(cls, id):
     cur = get_db().cursor()
     cur.execute(
         "SELECT max(fermenter_step.'order') as 'order' FROM %s WHERE fermenter_id = ?"
         % cls.__table_name__, (id, ))
     r = cur.fetchone()
     return r.get("order")
Beispiel #3
0
 def get_by_fermenter_id(cls, id):
     cur = get_db().cursor()
     cur.execute("SELECT * FROM %s WHERE fermenter_id = ?" % cls.__table_name__,(id,))
     result = []
     for r in cur.fetchall():
         result.append(cls(r))
     return result
Beispiel #4
0
 def get_by_state(cls, state, order=True):
     cur = get_db().cursor()
     cur.execute("SELECT * FROM %s WHERE state = ? ORDER BY %s.'order'" % (cls.__table_name__,cls.__table_name__,), state)
     r = cur.fetchone()
     if r is not None:
         return cls(r)
     else:
         return None
Beispiel #5
0
 def get_by_state(cls, state):
     cur = get_db().cursor()
     cur.execute("SELECT * FROM %s WHERE state = ?" % cls.__table_name__, state)
     r = cur.fetchone()
     if r is not None:
         return cls(r)
     else:
         return None
Beispiel #6
0
 def reset_all_steps(cls, id):
     cur = get_db().cursor()
     cur.execute(
         "UPDATE %s SET state = 'I', start = NULL, end = NULL, timer_start = NULL WHERE fermenter_id = ?"
         % cls.__table_name__, (id, ))
     get_db().commit()
Beispiel #7
0
 def update_timer(cls, id, timer):
     cur = get_db().cursor()
     cur.execute(
         "UPDATE %s SET timer_start = ? WHERE id =?" % cls.__table_name__,
         (timer, id))
     get_db().commit()
Beispiel #8
0
 def update_state(cls, id, state):
     cur = get_db().cursor()
     cur.execute("UPDATE %s SET state = ? WHERE id =?" % cls.__table_name__,
                 (state, id))
     get_db().commit()
Beispiel #9
0
 def reset_all_steps(cls):
     cur = get_db().cursor()
     cur.execute("UPDATE %s SET state = 'I', stepstate = NULL , start = NULL, end = NULL " % cls.__table_name__)
     get_db().commit()
Beispiel #10
0
 def delete_all(cls):
     cur = get_db().cursor()
     cur.execute("DELETE FROM %s" % cls.__table_name__)
     get_db().commit()
Beispiel #11
0
 def get_max_order(cls):
     cur = get_db().cursor()
     cur.execute("SELECT max(step.'order') as 'order' FROM %s" % cls.__table_name__)
     r = cur.fetchone()
     return r.get("order")