OperationalError: no such table: students
<p>As a beginner, I have been trying the tutorial at tutorialpoint for flask at url: <a href="http://www.tutorialspoint.com/flask/flask_sqlite.htm" rel="nofollow">http://www.tutorialspoint.com/flask/flask_sqlite.htm</a>. </p>

<p>However, after this error</p>

<p>jinja2.exceptions.TemplateNotFound
TemplateNotFound: home.html</p>

<p>Which should show:
 1. Add new record 
 2. Show List</p>

<p>I did the following:</p>

<pre><code>  &lt;h3&gt;Students (&lt;a href = "{{ url_for('new_student') }}"&gt;Add new record
     &lt;/a&gt;)&lt;/h3&gt;

   &lt;h3&gt; (&lt;a href = "{{ url_for('list') }}"&gt;Show List
     &lt;/a&gt;)&lt;/h3&gt;  
</code></pre>

<p>However, I think there may be other errors.</p>

<p>Now, I am getting the following error:</p>

<pre><code>  sqlite3.OperationalError
  OperationalError: no such table: students
</code></pre>

<p>Could anyone help make the tutorial work? Much appreciated.
*ps: Please do not flag down this post. If you can't or do not want to help. Just leave this question to people who are willing to help beginners. Thank you.</p>

<p>Ref:
<a href="http://www.tutorialspoint.com/flask/flask_sqlite.htm" rel="nofollow">http://www.tutorialspoint.com/flask/flask_sqlite.htm</a></p>

<p>Here are the copy and paste as requested by @Wayne:</p>

<p>‘student.html’ :</p>

<pre><code>&lt;html&gt;
   &lt;body&gt;

      &lt;form action = "{{ url_for('addrec') }}" method = "POST"&gt;
         &lt;h3&gt;Student Information&lt;/h3&gt;
         Name&lt;br&gt;
         &lt;input type = "text" name = "nm" /&gt;&lt;/br&gt;

         Address&lt;br&gt;
         &lt;textarea name = "add" &gt;&lt;/textarea&gt;&lt;br&gt;

         City&lt;br&gt;
         &lt;input type = "text" name = "city" /&gt;&lt;br&gt;

         PINCODE&lt;br&gt;
         &lt;input type = "text" name = "pin" /&gt;&lt;br&gt;
         &lt;input type = "submit" value = "submit" /&gt;&lt;br&gt;
      &lt;/form&gt;

   &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>result.html:</p>

<pre><code>&lt;!doctype html&gt;

    &lt;html&gt;
       &lt;body&gt;

          result of addition : {{ msg }}
          &lt;h2&gt;&lt;a href = "\"&gt;go back to home page&lt;/a&gt;&lt;/h2&gt;

       &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>list.html :</p>

<pre><code>&lt;!doctype html&gt;
&lt;html&gt;
   &lt;body&gt;

      &lt;table border = 1&gt;
         &lt;thead&gt;
            &lt;td&gt;Name&lt;/td&gt;
            &lt;td&gt;Address&gt;/td&lt;
            &lt;td&gt;city&lt;/td&gt;
            &lt;td&gt;Pincode&lt;/td&gt;
         &lt;/thead&gt;

         {% for row in rows %}
            &lt;tr&gt;
               &lt;td&gt;{{row["name"]}}&lt;/td&gt;
               &lt;td&gt;{{row["addr"]}}&lt;/td&gt;
               &lt;td&gt; {{ row["city"]}}&lt;/td&gt;
               &lt;td&gt;{{row['pin']}}&lt;/td&gt;  
            &lt;/tr&gt;
         {% endfor %}
      &lt;/table&gt;

      &lt;a href = "/"&gt;Go back to home page&lt;/a&gt;

   &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Flask-SQLite application:</p>

<pre><code>from flask import Flask, render_template, request
import sqlite3 as sql
app = Flask(__name__)

@app.route('/')
def home():
   return render_template('home.html')

@app.route('/enternew')
def new_student():
   return render_template('student.html')

@app.route('/addrec',methods = ['POST', 'GET'])
def addrec():
   if request.method == 'POST':
      try:
         nm = request.form['nm']
         addr = request.form['add']
         city = request.form['city']
         pin = request.form['pin']

         with sql.connect("database.db") as con:
            cur = con.cursor()

            cur.execute("INSERT INTO students (name,addr,city,pin) 
               VALUES (?,?,?,?)",(nm,addr,city,pin) )

            con.commit()
            msg = "Record successfully added"
      except:
         con.rollback()
         msg = "error in insert operation"

      finally:
         return render_template("result.html",msg = msg)
         con.close()

@app.route('/list')
def list():
   con = sql.connect("database.db")
   con.row_factory = sql.Row

   cur = con.cursor()
   cur.execute("select * from students")

   rows = cur.fetchall();
   return render_template("list.html",rows = rows)

if __name__ == '__main__':
   app.run(debug = True)
</code></pre>