Flask framework error
<p>Hi guys i am getting an error and i am not sure what it means after looking at it for a lil while...</p>

<p>here is the error:</p>

<pre><code>vagrant@vagrant-ubuntu-trusty-32:/vagrant/PayUp$ python setup_database.py
Traceback (most recent call last):
  File "setup_database.py", line 58, in &lt;module&gt;
    Base.metadata.create_all(engine)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 2848, in create_all
    tables=tables)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1479, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1122, in _run_visitor
    **kwargs).traverse_single(element)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 122, in traverse_single
    return meth(obj, **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/ddl.py", line 57, in visit_metadata
    if self._can_create_table(t)]
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/ddl.py", line 35, in _can_create_table
    table.name, schema=table.schema)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/dialects/sqlite/base.py", line 722, in has_table
    cursor = _pragma_cursor(connection.execute(statement))
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 662, in execute
    params)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 805, in _execute_text
    statement, parameters
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 874, in _execute_context
    context)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception
    exc_info
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 196, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 867, in _execute_context
    context)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 324, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (DatabaseError) database disk image is malformed 'PRAGMA table_info("users")' ()
</code></pre>

<p>i was looking at it i didnt really understand what the error was saying</p>

<p>Here is the code that i have for creating my database which was not getting error and the server setup file which is where my server would hold.</p>

<pre><code>from flask import Flaskfrom sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from setup_database import Base, Users, User_Auth, User_info, User_Location

# The following line is what initiates the flask app for this project
app = Flask(__name__)

engine = create_engine('sqlite:///payup.db')
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

@app.route('/')
def HomePage():
    output = "&lt;h1&gt;hello&lt;/h1&gt;"

@app.route('/users')
def UsersList(users.id):
    output = "&lt;h1&gt;This page will list all of the current users&lt;/h1&gt;"

@app.route('/adduser')
def CreateNewUser(users):
    output = "&lt;h1&gt;This page will be able to create new users&lt;/h1&gt;"

@app.route('/manageUsers')
def ManageUsers(users.id):
    output = "&lt;h1&gt;This page will be able to manage all of the users&lt;/h1&gt;"

@app.route('/userProfile')
def UsersProfile(all of the tables):
    output = "&lt;h1&gt;This page will display all of the users informaiton &lt;/h1&gt;"

if __name__ == '__main__':
    app.debug = True
    app.run(host = '0.0.0.0', port = 5555)
</code></pre>

<p>Because you're using SQLite, the error message <code>sqlalchemy.exc.DatabaseError: (DatabaseError) database disk image is malformed 'PRAGMA table_info("users")' ()</code> leads to the assumption that there is something wrong with your database file called <code>payup.db</code>.</p>

<p>Moving or deleting the possibly corrupt SQLite database file should help you to get your script to run without errors. Upon successful execution (and server start), a new SQLite database file should have been created automatically by SQLAlchemy.</p>

python flask sqlalchemy flask-sqlalchemy