コード例 #1
0
def get_pomodoros(db_name):
    """Get the pomodoro data from the database"""
    conn = db.startup(db_name)
    pomodoros = db.get_data(conn)
    db.shutdown(conn)

    return pomodoros
コード例 #2
0
def do_pomodoro(duration, name):
    """Main method. Starts up, runs pomodoro and records it"""
    connection = db.startup("pomodoros.db")
    task, start_time = pomodoro_start(connection, name)
    complete, length = pomodoro_time(start_time, duration)

    # Use string of length because timedelta is unsupported in sqlite
    row = (start_time, task, str(length), complete)
    db.insert(connection, row)

    db.shutdown(connection)
コード例 #3
0
def get_last_n_pomodoros(db_name, num=1):
    """Get the last x pomodoros from the database"""
    connection = db.startup(db_name)
    cur = connection.cursor()

    db_query = "SELECT * FROM pomodoros ORDER BY datetime DESC LIMIT {};".format(num)
    pomodoros = cur.execute(db_query).fetchall()

    db.shutdown(connection)
    
    return pomodoros
コード例 #4
0
def get_pomodoros_between_dates(db_name, date1, date2):
    """Get all pomodoros between two dates (inclusive)"""
    connection = db.startup(db_name)
    cur = connection.cursor()

    query_base = "SELECT * FROM pomodoros WHERE datetime BETWEEN '{0}' AND '{1}';"
    db_query = query_base.format(date1, date2)
    pomodoros = cur.execute(db_query).fetchall()

    db.shutdown(connection)
    
    return pomodoros