def create_course(course, commit=True):
     sql = "insert into courses values (default, %s, %s, %s, %s, %s, %s) Returning id"
     cursor = connection.cursor()
     cursor.execute(sql, [
         course.name, course.type.id, course.start_date, course.end_date,
         course.grading_format.id, course.cost
     ])
     connection.commit() if commit else connection.rollback()
     return cursor.fetchone()
示例#2
0
 def update_account(changing_account):
     sql = "Update accounts set account_type=%s, balance=%s where id=%s"
     cursor = connection.cursor()
     cursor.execute(sql, [
         changing_account.account_type, changing_account.balance,
         changing_account.id
     ])
     connection.commit()
     return cursor.rowcount
示例#3
0
 def create_account(account, client_id):
     try:
         sql = "Insert into accounts values (default, %s, %s, %s)"
         cursor = connection.cursor()
         cursor.execute(sql,
                        [client_id, account.account_type, account.balance])
         connection.commit()
         return "Successfully added Account"
     except:
         return "No client found", 404
     finally:
         connection.commit()
 def create_reimbursement(reimbursement, commit=True):
     if reimbursement.course.id is None:
         reimbursement.course.id = CourseDao.create_course(
             reimbursement.course)
     status = 1
     if not reimbursement.employee.supervisor:
         status = 2
     sql = "insert into reimbursements values (default, %s, %s, %s, %s, %s, %s)"
     cursor = connection.cursor()
     cursor.execute(sql, [
         reimbursement.employee.id, status, reimbursement.date_submitted,
         reimbursement.course.id, reimbursement.amount,
         reimbursement.message
     ])
     connection.commit() if commit else connection.rollback()
     return True
示例#5
0
 def delete_account(client_id, account_id):
     sql = "Delete from accounts where id = %s and client_id = %s"
     cursor = connection.cursor()
     cursor.execute(sql, [account_id, client_id])
     connection.commit()
     return cursor.rowcount
示例#6
0
 def create_client(client):
     sql = "Insert into clients values (default, %s)"
     cursor = connection.cursor()
     cursor.execute(sql, [client.name])
     connection.commit()
     return True
示例#7
0
 def delete_client(id):
     sql = "Delete from clients where id = %s"
     cursor = connection.cursor()
     cursor.execute(sql, [id])
     connection.commit()
     return cursor.rowcount
示例#8
0
 def update_client(changing_client):
     sql = "Update clients set name=%s where id=%s"
     cursor = connection.cursor()
     cursor.execute(sql, [changing_client.name, changing_client.id])
     connection.commit()
     return cursor.rowcount
 def update_reimbursement(id, status_id, message, amount, commit=True):
     sql = "update reimbursements set status_id = %s, message=%s, amount=%s where id=%s"
     cursor = connection.cursor()
     cursor.execute(sql, [status_id, message, amount, id])
     connection.commit() if commit else connection.rollback()
     return str(cursor.rowcount)