func GetTaskByID(username string, id int) (types.Context, error) {
	var tasks []types.Task
	var task types.Task
	getTaskSQL := "select t.id, t.title, t.content, t.priority, t.hide, c.name from task t join user u left outer join category c where c.id = t.cat_id and t.user_id=u.id and t.id=? and u.username=? union select t.id, t.title, t.content, t.priority, t.hide, 'UNCATEGORIZED' from task t join user u where t.user_id=u.id and t.cat_id=0 and t.id=? and u.username=?;"
	rows := database.query(getTaskSQL, id, username, id, username)
	defer rows.Close()
	if rows.Next() {
		err := rows.Scan(&task.Id, &task.Title, &task.Content, &task.Priority, &task.IsHidden, &task.Category)
		if err != nil {
			log.Println(err)
		}
	}
	tasks = append(tasks, task)
	context := types.Context{Tasks: tasks, Navigation: "edit"}
	return context, nil
}
GetTaskByID function gets the tasks from the ID passed to the function, used to populate EditTask
package db
import (
	"database/sql"
	"html/template"
	"log"
	"strconv"
	"strings"
	"time"
	_ "github.com/mattn/go-sqlite3"  
	md "github.com/shurcooL/github_flavored_markdown"
	"github.com/thewhitetulip/Tasks/types"
)
var database Database
var taskStatus map[string]int
var err error
type Database struct {
	db *sql.DB
}
func (db Database) begin() (tx *sql.Tx) {
	tx, err := db.db.Begin()
	if err != nil {
		log.Println(err)
		return nil
	}
	return tx
}
func (db Database) prepare(q string) (stmt *sql.Stmt) {
	stmt, err := db.db.Prepare(q)
	if err != nil {
		log.Println(err)
		return nil
	}
	return stmt
}
func (db Database) query(q string, args ...interface{}) (rows *sql.Rows) {
	rows, err := db.db.Query(q, args...)
	if err != nil {
		log.Println(err)
		return nil
	}
	return rows
}
func init() {
	database.db, err = sql.Open("sqlite3", "./tasks.db")
	taskStatus = map[string]int{"COMPLETE": 1, "PENDING": 2, "DELETED": 3}
	if err != nil {
		log.Fatal(err)
	}
}
func Close() {
	database.db.Close()
}
func GetTasks(username, status, category string) (types.Context, error) {
	log.Println("getting tasks for ", status)
	var tasks []types.Task
	var task types.Task
	var TaskCreated time.Time
	var context types.Context
	var getTaskSQL string
	var rows *sql.Rows
	comments, err := GetComments(username)
	if err != nil {
		return context, err
	}
	basicSQL := "select t.id, title, content, created_date, priority, case when c.name is null then 'NA' else c.name end from task t, status s, user u left outer join  category c on c.id=t.cat_id where u.username=? and s.id=t.task_status_id and u.id=t.user_id "
	if category == "" {
		switch status {
		case "pending":
			getTaskSQL = basicSQL + " and s.status='PENDING' and t.hide!=1"
		case "deleted":
			getTaskSQL = basicSQL + " and s.status='DELETED' and t.hide!=1"
		case "completed":
			getTaskSQL = basicSQL + " and s.status='COMPLETE' and t.hide!=1"
		}
		getTaskSQL += " order by t.created_date asc"
		rows = database.query(getTaskSQL, username, username)
	} else {
		status = category
		if category == "UNCATEGORIZED" {
			getTaskSQL = "select t.id, title, content, created_date, priority, 'UNCATEGORIZED' from task t, status s, user u where u.username=? and s.id=t.task_status_id and u.id=t.user_id and t.cat_id=0  and  s.status='PENDING'  order by priority desc, created_date asc, finish_date asc"
			rows, err = database.db.Query(getTaskSQL, username)
		} else {
			getTaskSQL = basicSQL + " and name = ?  and  s.status='PENDING'  order by priority desc, created_date asc, finish_date asc"
			rows, err = database.db.Query(getTaskSQL, username, category)
		}
		if err != nil {
			log.Println("tasks.go: something went wrong while getting query fetch tasks by category")
		}
	}
	defer rows.Close()
	for rows.Next() {
		task = types.Task{}
		err = rows.Scan(&task.Id, &task.Title, &task.Content, &TaskCreated, &task.Priority, &task.Category)
		taskCompleted := 0
		totalTasks := 0
		if strings.HasPrefix(task.Content, "- [") {
			for _, value := range strings.Split(task.Content, "\n") {
				if strings.HasPrefix(value, "- [x]") {
					taskCompleted += 1
				}
				totalTasks += 1
			}
			task.CompletedMsg = strconv.Itoa(taskCompleted) + " complete out of " + strconv.Itoa(totalTasks)
		}
		task.ContentHTML = template.HTML(md.Markdown([]byte(task.Content)))
		if err != nil {
			log.Println(err)
		}
		if comments[task.Id] != nil {
			task.Comments = comments[task.Id]
		}
		TaskCreated = TaskCreated.Local()
		task.Created = TaskCreated.Format("Jan 2 2006")
		tasks = append(tasks, task)
	}
	context = types.Context{Tasks: tasks, Navigation: status}
	return context, nil
}