title: Python doesn't commit data to SQLite database
body: <p>This code should insert and save these two records to my database every time I run this code, but it doesn't work.</p>
  <p>There is no errors, everything works fine except commiting changes to database and I don't know why.</p>
  <pre><code>import sqlite3
  
  conn = sqlite3.connect('SQLite_Python.db')
  c = conn.cursor()
  
  c.execute(&quot;&quot;&quot;DROP TABLE IF EXISTS expenses;&quot;&quot;&quot;)
  c.execute(&quot;&quot;&quot;CREATE TABLE expenses (
              name text,
              amount text,
              date_of_expense text,
              category text,
              notes text
              )&quot;&quot;&quot;)
  
  def insert_expense(exp):
      with conn:
          c.execute(&quot;INSERT INTO expenses VALUES (?, ?, ?, ?, ?)&quot;, 
              (exp.name, exp.amount, exp.date_of_expense, exp.category, exp.notes))
  
  
  def get_all_expenses():
      c.execute(&quot;SELECT * FROM expenses&quot;)
      return c.fetchall()
  
  exp1 = Expense('apple', '5.50', '02:12:1202','food', '-')
  exp2 = Expense('orange', '9.90', '05:02:1892', 'food', '-')
  
  insert_expense(exp1)
  insert_expense(exp2)
  
  exps = get_expense_by_category('food')
  print(exps)
  
  conn.commit()
  conn.close()
  </code></pre>
  <p>My goal is to save records to database and when I open this database again, I want to see old records.</p>