title: How to make Python not overwrite a SQLite entry
body: <p>I have a sign-in/sign-out function for students. The problem is that if they sign in a third time on the same day the code is overwriting their previous time_out timestamp. How can I make it not replace the last time_out Timestamp if a student accidentally signs out a third time.  </p>
  
  <pre><code>import sqlite3
  import datetime
  import time  # used for sleep command
  ​
  conn = sqlite3.connect('attendance.db')
  ​
  c = conn.cursor()
  ​
  ​
  # def create_db():
  #     c.execute("""CREATE TABLE students (
  #                 first text,
  #                 date text,
  #                 status_in text,
  #                 time_in text,
  #                 status_out text,
  #                 time_out text
  #                 )""")
  #     conn.commit()
  #     conn.close()
  ​
  ​
  # Check if name has a daily entry, if doesnt exist store time_in timestamp
  # If a timestamp already exists on that day put an time_out timestamp
  def check_if_in():
      person = input('Name of student checking IN/OUT: ')
      date = datetime.date.today().strftime("%m-%d-%y")
      c.execute('SELECT status_in FROM students '
                'WHERE first = ? AND date = ?', [person, date])
      conn.commit()
      result = c.fetchone()
      if result is None:
          status_in = 'IN'
          timestamp = time.strftime('%I:%M %p')
          day = datetime.date.today().strftime('%m-%d-%y')
          c.execute("INSERT INTO students (first, date, status_in, time_in) "
                    "VALUES(?, ?, ?, ?)", [person, day, status_in, timestamp])
          conn.commit()
          check_if_in()
      else:
          c.execute("SELECT status_in FROM students "
                    "WHERE first = ? AND date = ?", [person, date])
          conn.commit()
          result2 = c.fetchone()
          convert = ''.join(map(str, result2))
          if convert == 'IN':
              timestamp = time.strftime('%I:%M %p')
              c.execute("UPDATE students SET status_out = 'OUT' "
                        "WHERE first = ? and date = ?", [person, date])
              c.execute("UPDATE students SET time_out = ? "
                        "WHERE first = ? and date = ?", [timestamp, person, date])
              conn.commit()
              check_if_in()
          else:
              print('This will direct somewhere else')
  ​
  ​
  check_if_in()
  #create_db()
  </code></pre>