Flask-SQLAlchemy app fails to create tables










0















Context: I'm creating my first flask web app as a twitter clone in which developers can post "dev logs" to a game they're developing.



From what I've learned in this tutorial, I've repackaged my app to become four python modules. I'm still a bit confused and I think I got some things wrong, but when I run the program through the script below:



from home import app

if __name__ == "__main__":
app.run(debug=True)


Where home is the name of my flask app. Running this outputs this error:



Traceback (most recent call last):
File "run.py", line 1, in <module>
from home import app
File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/__init__.py", line 11, in <module>
from home import routes
File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/routes.py", line 10, in <module>
db.session.commit()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
self.transaction.commit()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
self._prepare_impl()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
self.session.flush()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
self._flush(objects)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2381, in _flush
transaction.rollback(_capture_exception=True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2345, in _flush
flush_context.execute()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 395, in execute
rec.execute(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 560, in execute
uow
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
mapper, table, insert)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
execute(statement, params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
return meth(self, multiparams, params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
context)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
exc_info
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 248, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
context)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: 'INSERT INTO user (username, password) VALUES (?, ?)'] [parameters: ('admin', 'admin123')] (Background on this error at: http://sqlalche.me/e/e3q8)


This is my init file:



from flask import Flask
from flask_session import Session

# Set's up the app with the given name
app = Flask(__name__)
# Secret key for sessions
app.config['SECRET_KEY'] = 'eb02cfb5079a2b6bdeb8bddb69ca937b'
# Sets up config for database with SQLite, which is easy to set up.
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'

from home import routes
from home.models import *

db.create_all()


Below is routes.py:



from flask import render_template, url_for, flash
import os, datetime
from home import app
from home.models import db

#dummy data
import home.models
theUser = home.models.User(username='admin', password='admin123')
db.session.add(theUser)
db.session.commit()
admin = home.models.User.query.filter_by(username='admin').first()
zombies = home.models.Games(game='Shoot Zombies!', user_id=admin.id)
ball = home.models.Games(game='Bounce & Ball', user_id=admin.id)
db.session.add(zombies)
db.session.add(ball)
db.session.commit()

def getCurrentUser():
return admin

from home import posts

@app.route("/", methods=['GET', 'POST'])
def index():
form = posts.WriteLog()
if form.validate_on_submit():
username = current_user.username
post = form.devLog.data
game = Games.query.filter_by(game=form.gameSelect.data).first().id
title = form.title.date
newPost = Post(title=title, game_id=game, content=post)
return render_template("index.html", form=form, data=Post)
return render_template("index.html", form=form, data=Post)


Below is models.py:



from home import app
from flask_sqlalchemy import SQLAlchemy
import os, datetime

# Sets up SQL Database
db = SQLAlchemy(app)

### Database Stuff ###
# Creates a table for the user

class User(db.Model):
__tablename__ = "user"
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), nullable=False)
password = db.Column(db.String(20), nullable=False)
games = db.relationship('Games', backref="user", lazy=True)

def __repr__(self):
return f"User('self.username', 'self.password', 'self.games')"

# Creates a table for games
class Games(db.Model):
__tablename__ = "game"
id = db.Column(db.Integer, primary_key=True)
game = db.Column(db.String(40), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
logs = db.relationship('Post', backref="game", lazy=True)

def __repr__(self):
return f"Game('self.game', 'self.logs')"

class Post(db.Model):
__tablename__ = "post"
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100), nullable=False)
date_posted = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False)
content = db.Column(db.Text, nullable=False)

def __repr__(self):
return f"Post('self.title', 'self.date_posted', 'self.game_id', 'self.content')"


And posts.py is just an app which manages the forms. As I understand it, the User table was not created. However, I have run the db.create_all() command in the init file. Help would be appreciated!



UPDATE: Now I have a new bug.



sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: http://sqlalche.me/e/f405)


For reference, this is my index.html file:



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>DevlogIO</title>
<link rel="stylesheet" href=" url_for('static', filename='style.css') ">
</head>
<body>
<div id="container">
<h1>Devlog IO</h1>
<h2>Home</h2>
<p>See the progress of your favorite developers, and discover new and rising game developers!</p>
<div>
<form action="" method="POST">
form.hidden_tag()
<fieldset>
<legend>What was your progress for today?</legend>
<div>
form.gameSelect(class="")
</div>
<br>
<div>
form.title.label(class="")
form.title(class="")
</div>
<br>
<div>
form.devLog.label(class="")
form.devLog(class="")
</div>
<br>
<div>
form.submit(class="")
</div>
<br>
</fieldset>
</form>
</div>
<hr>
<div id="stream">
% for post in data.query.all() %
<fieldset>
<p><strong> post.title , form.gameSelect.data </strong></p>
<p><i>by post.game_id </i></p>
<p><i> post.date_posted </i></p>
<p> post.content </p>
</fieldset>
<br>
% endfor %
</div>

</div>

<script src=" url_for('static', filename='script.js') "></script>
</body>
</html>









share|improve this question




























    0















    Context: I'm creating my first flask web app as a twitter clone in which developers can post "dev logs" to a game they're developing.



    From what I've learned in this tutorial, I've repackaged my app to become four python modules. I'm still a bit confused and I think I got some things wrong, but when I run the program through the script below:



    from home import app

    if __name__ == "__main__":
    app.run(debug=True)


    Where home is the name of my flask app. Running this outputs this error:



    Traceback (most recent call last):
    File "run.py", line 1, in <module>
    from home import app
    File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/__init__.py", line 11, in <module>
    from home import routes
    File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/routes.py", line 10, in <module>
    db.session.commit()
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
    return getattr(self.registry(), name)(*args, **kwargs)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
    self.transaction.commit()
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
    self._prepare_impl()
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
    self.session.flush()
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
    self._flush(objects)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2381, in _flush
    transaction.rollback(_capture_exception=True)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
    raise value
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2345, in _flush
    flush_context.execute()
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 395, in execute
    rec.execute(self)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 560, in execute
    uow
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
    mapper, table, insert)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
    execute(statement, params)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 248, in reraise
    raise value.with_traceback(tb)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
    cursor.execute(statement, parameters)
    sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: 'INSERT INTO user (username, password) VALUES (?, ?)'] [parameters: ('admin', 'admin123')] (Background on this error at: http://sqlalche.me/e/e3q8)


    This is my init file:



    from flask import Flask
    from flask_session import Session

    # Set's up the app with the given name
    app = Flask(__name__)
    # Secret key for sessions
    app.config['SECRET_KEY'] = 'eb02cfb5079a2b6bdeb8bddb69ca937b'
    # Sets up config for database with SQLite, which is easy to set up.
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'

    from home import routes
    from home.models import *

    db.create_all()


    Below is routes.py:



    from flask import render_template, url_for, flash
    import os, datetime
    from home import app
    from home.models import db

    #dummy data
    import home.models
    theUser = home.models.User(username='admin', password='admin123')
    db.session.add(theUser)
    db.session.commit()
    admin = home.models.User.query.filter_by(username='admin').first()
    zombies = home.models.Games(game='Shoot Zombies!', user_id=admin.id)
    ball = home.models.Games(game='Bounce & Ball', user_id=admin.id)
    db.session.add(zombies)
    db.session.add(ball)
    db.session.commit()

    def getCurrentUser():
    return admin

    from home import posts

    @app.route("/", methods=['GET', 'POST'])
    def index():
    form = posts.WriteLog()
    if form.validate_on_submit():
    username = current_user.username
    post = form.devLog.data
    game = Games.query.filter_by(game=form.gameSelect.data).first().id
    title = form.title.date
    newPost = Post(title=title, game_id=game, content=post)
    return render_template("index.html", form=form, data=Post)
    return render_template("index.html", form=form, data=Post)


    Below is models.py:



    from home import app
    from flask_sqlalchemy import SQLAlchemy
    import os, datetime

    # Sets up SQL Database
    db = SQLAlchemy(app)

    ### Database Stuff ###
    # Creates a table for the user

    class User(db.Model):
    __tablename__ = "user"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), nullable=False)
    password = db.Column(db.String(20), nullable=False)
    games = db.relationship('Games', backref="user", lazy=True)

    def __repr__(self):
    return f"User('self.username', 'self.password', 'self.games')"

    # Creates a table for games
    class Games(db.Model):
    __tablename__ = "game"
    id = db.Column(db.Integer, primary_key=True)
    game = db.Column(db.String(40), nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    logs = db.relationship('Post', backref="game", lazy=True)

    def __repr__(self):
    return f"Game('self.game', 'self.logs')"

    class Post(db.Model):
    __tablename__ = "post"
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
    game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False)
    content = db.Column(db.Text, nullable=False)

    def __repr__(self):
    return f"Post('self.title', 'self.date_posted', 'self.game_id', 'self.content')"


    And posts.py is just an app which manages the forms. As I understand it, the User table was not created. However, I have run the db.create_all() command in the init file. Help would be appreciated!



    UPDATE: Now I have a new bug.



    sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: http://sqlalche.me/e/f405)


    For reference, this is my index.html file:



    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>DevlogIO</title>
    <link rel="stylesheet" href=" url_for('static', filename='style.css') ">
    </head>
    <body>
    <div id="container">
    <h1>Devlog IO</h1>
    <h2>Home</h2>
    <p>See the progress of your favorite developers, and discover new and rising game developers!</p>
    <div>
    <form action="" method="POST">
    form.hidden_tag()
    <fieldset>
    <legend>What was your progress for today?</legend>
    <div>
    form.gameSelect(class="")
    </div>
    <br>
    <div>
    form.title.label(class="")
    form.title(class="")
    </div>
    <br>
    <div>
    form.devLog.label(class="")
    form.devLog(class="")
    </div>
    <br>
    <div>
    form.submit(class="")
    </div>
    <br>
    </fieldset>
    </form>
    </div>
    <hr>
    <div id="stream">
    % for post in data.query.all() %
    <fieldset>
    <p><strong> post.title , form.gameSelect.data </strong></p>
    <p><i>by post.game_id </i></p>
    <p><i> post.date_posted </i></p>
    <p> post.content </p>
    </fieldset>
    <br>
    % endfor %
    </div>

    </div>

    <script src=" url_for('static', filename='script.js') "></script>
    </body>
    </html>









    share|improve this question


























      0












      0








      0








      Context: I'm creating my first flask web app as a twitter clone in which developers can post "dev logs" to a game they're developing.



      From what I've learned in this tutorial, I've repackaged my app to become four python modules. I'm still a bit confused and I think I got some things wrong, but when I run the program through the script below:



      from home import app

      if __name__ == "__main__":
      app.run(debug=True)


      Where home is the name of my flask app. Running this outputs this error:



      Traceback (most recent call last):
      File "run.py", line 1, in <module>
      from home import app
      File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/__init__.py", line 11, in <module>
      from home import routes
      File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/routes.py", line 10, in <module>
      db.session.commit()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
      return getattr(self.registry(), name)(*args, **kwargs)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
      self.transaction.commit()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
      self._prepare_impl()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
      self.session.flush()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
      self._flush(objects)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2381, in _flush
      transaction.rollback(_capture_exception=True)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
      compat.reraise(exc_type, exc_value, exc_tb)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
      raise value
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2345, in _flush
      flush_context.execute()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 395, in execute
      rec.execute(self)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 560, in execute
      uow
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
      mapper, table, insert)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
      execute(statement, params)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
      return meth(self, multiparams, params)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
      return connection._execute_clauseelement(self, multiparams, params)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
      compiled_sql, distilled_params
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
      context)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
      exc_info
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
      reraise(type(exception), exception, tb=exc_tb, cause=cause)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 248, in reraise
      raise value.with_traceback(tb)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
      context)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
      cursor.execute(statement, parameters)
      sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: 'INSERT INTO user (username, password) VALUES (?, ?)'] [parameters: ('admin', 'admin123')] (Background on this error at: http://sqlalche.me/e/e3q8)


      This is my init file:



      from flask import Flask
      from flask_session import Session

      # Set's up the app with the given name
      app = Flask(__name__)
      # Secret key for sessions
      app.config['SECRET_KEY'] = 'eb02cfb5079a2b6bdeb8bddb69ca937b'
      # Sets up config for database with SQLite, which is easy to set up.
      app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'

      from home import routes
      from home.models import *

      db.create_all()


      Below is routes.py:



      from flask import render_template, url_for, flash
      import os, datetime
      from home import app
      from home.models import db

      #dummy data
      import home.models
      theUser = home.models.User(username='admin', password='admin123')
      db.session.add(theUser)
      db.session.commit()
      admin = home.models.User.query.filter_by(username='admin').first()
      zombies = home.models.Games(game='Shoot Zombies!', user_id=admin.id)
      ball = home.models.Games(game='Bounce & Ball', user_id=admin.id)
      db.session.add(zombies)
      db.session.add(ball)
      db.session.commit()

      def getCurrentUser():
      return admin

      from home import posts

      @app.route("/", methods=['GET', 'POST'])
      def index():
      form = posts.WriteLog()
      if form.validate_on_submit():
      username = current_user.username
      post = form.devLog.data
      game = Games.query.filter_by(game=form.gameSelect.data).first().id
      title = form.title.date
      newPost = Post(title=title, game_id=game, content=post)
      return render_template("index.html", form=form, data=Post)
      return render_template("index.html", form=form, data=Post)


      Below is models.py:



      from home import app
      from flask_sqlalchemy import SQLAlchemy
      import os, datetime

      # Sets up SQL Database
      db = SQLAlchemy(app)

      ### Database Stuff ###
      # Creates a table for the user

      class User(db.Model):
      __tablename__ = "user"
      id = db.Column(db.Integer, primary_key=True)
      username = db.Column(db.String(20), nullable=False)
      password = db.Column(db.String(20), nullable=False)
      games = db.relationship('Games', backref="user", lazy=True)

      def __repr__(self):
      return f"User('self.username', 'self.password', 'self.games')"

      # Creates a table for games
      class Games(db.Model):
      __tablename__ = "game"
      id = db.Column(db.Integer, primary_key=True)
      game = db.Column(db.String(40), nullable=False)
      user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
      logs = db.relationship('Post', backref="game", lazy=True)

      def __repr__(self):
      return f"Game('self.game', 'self.logs')"

      class Post(db.Model):
      __tablename__ = "post"
      id = db.Column(db.Integer, primary_key=True)
      title = db.Column(db.String(100), nullable=False)
      date_posted = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
      game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False)
      content = db.Column(db.Text, nullable=False)

      def __repr__(self):
      return f"Post('self.title', 'self.date_posted', 'self.game_id', 'self.content')"


      And posts.py is just an app which manages the forms. As I understand it, the User table was not created. However, I have run the db.create_all() command in the init file. Help would be appreciated!



      UPDATE: Now I have a new bug.



      sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: http://sqlalche.me/e/f405)


      For reference, this is my index.html file:



      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>DevlogIO</title>
      <link rel="stylesheet" href=" url_for('static', filename='style.css') ">
      </head>
      <body>
      <div id="container">
      <h1>Devlog IO</h1>
      <h2>Home</h2>
      <p>See the progress of your favorite developers, and discover new and rising game developers!</p>
      <div>
      <form action="" method="POST">
      form.hidden_tag()
      <fieldset>
      <legend>What was your progress for today?</legend>
      <div>
      form.gameSelect(class="")
      </div>
      <br>
      <div>
      form.title.label(class="")
      form.title(class="")
      </div>
      <br>
      <div>
      form.devLog.label(class="")
      form.devLog(class="")
      </div>
      <br>
      <div>
      form.submit(class="")
      </div>
      <br>
      </fieldset>
      </form>
      </div>
      <hr>
      <div id="stream">
      % for post in data.query.all() %
      <fieldset>
      <p><strong> post.title , form.gameSelect.data </strong></p>
      <p><i>by post.game_id </i></p>
      <p><i> post.date_posted </i></p>
      <p> post.content </p>
      </fieldset>
      <br>
      % endfor %
      </div>

      </div>

      <script src=" url_for('static', filename='script.js') "></script>
      </body>
      </html>









      share|improve this question
















      Context: I'm creating my first flask web app as a twitter clone in which developers can post "dev logs" to a game they're developing.



      From what I've learned in this tutorial, I've repackaged my app to become four python modules. I'm still a bit confused and I think I got some things wrong, but when I run the program through the script below:



      from home import app

      if __name__ == "__main__":
      app.run(debug=True)


      Where home is the name of my flask app. Running this outputs this error:



      Traceback (most recent call last):
      File "run.py", line 1, in <module>
      from home import app
      File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/__init__.py", line 11, in <module>
      from home import routes
      File "/Users/AdityaD/iCloud Drive (Archive)/Desktop/DevlogIO/home/routes.py", line 10, in <module>
      db.session.commit()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
      return getattr(self.registry(), name)(*args, **kwargs)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
      self.transaction.commit()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
      self._prepare_impl()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
      self.session.flush()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
      self._flush(objects)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2381, in _flush
      transaction.rollback(_capture_exception=True)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
      compat.reraise(exc_type, exc_value, exc_tb)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
      raise value
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2345, in _flush
      flush_context.execute()
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 395, in execute
      rec.execute(self)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 560, in execute
      uow
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
      mapper, table, insert)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
      execute(statement, params)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
      return meth(self, multiparams, params)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
      return connection._execute_clauseelement(self, multiparams, params)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
      compiled_sql, distilled_params
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
      context)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
      exc_info
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
      reraise(type(exception), exception, tb=exc_tb, cause=cause)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 248, in reraise
      raise value.with_traceback(tb)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
      context)
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
      cursor.execute(statement, parameters)
      sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: 'INSERT INTO user (username, password) VALUES (?, ?)'] [parameters: ('admin', 'admin123')] (Background on this error at: http://sqlalche.me/e/e3q8)


      This is my init file:



      from flask import Flask
      from flask_session import Session

      # Set's up the app with the given name
      app = Flask(__name__)
      # Secret key for sessions
      app.config['SECRET_KEY'] = 'eb02cfb5079a2b6bdeb8bddb69ca937b'
      # Sets up config for database with SQLite, which is easy to set up.
      app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'

      from home import routes
      from home.models import *

      db.create_all()


      Below is routes.py:



      from flask import render_template, url_for, flash
      import os, datetime
      from home import app
      from home.models import db

      #dummy data
      import home.models
      theUser = home.models.User(username='admin', password='admin123')
      db.session.add(theUser)
      db.session.commit()
      admin = home.models.User.query.filter_by(username='admin').first()
      zombies = home.models.Games(game='Shoot Zombies!', user_id=admin.id)
      ball = home.models.Games(game='Bounce & Ball', user_id=admin.id)
      db.session.add(zombies)
      db.session.add(ball)
      db.session.commit()

      def getCurrentUser():
      return admin

      from home import posts

      @app.route("/", methods=['GET', 'POST'])
      def index():
      form = posts.WriteLog()
      if form.validate_on_submit():
      username = current_user.username
      post = form.devLog.data
      game = Games.query.filter_by(game=form.gameSelect.data).first().id
      title = form.title.date
      newPost = Post(title=title, game_id=game, content=post)
      return render_template("index.html", form=form, data=Post)
      return render_template("index.html", form=form, data=Post)


      Below is models.py:



      from home import app
      from flask_sqlalchemy import SQLAlchemy
      import os, datetime

      # Sets up SQL Database
      db = SQLAlchemy(app)

      ### Database Stuff ###
      # Creates a table for the user

      class User(db.Model):
      __tablename__ = "user"
      id = db.Column(db.Integer, primary_key=True)
      username = db.Column(db.String(20), nullable=False)
      password = db.Column(db.String(20), nullable=False)
      games = db.relationship('Games', backref="user", lazy=True)

      def __repr__(self):
      return f"User('self.username', 'self.password', 'self.games')"

      # Creates a table for games
      class Games(db.Model):
      __tablename__ = "game"
      id = db.Column(db.Integer, primary_key=True)
      game = db.Column(db.String(40), nullable=False)
      user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
      logs = db.relationship('Post', backref="game", lazy=True)

      def __repr__(self):
      return f"Game('self.game', 'self.logs')"

      class Post(db.Model):
      __tablename__ = "post"
      id = db.Column(db.Integer, primary_key=True)
      title = db.Column(db.String(100), nullable=False)
      date_posted = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
      game_id = db.Column(db.Integer, db.ForeignKey('game.id'), nullable=False)
      content = db.Column(db.Text, nullable=False)

      def __repr__(self):
      return f"Post('self.title', 'self.date_posted', 'self.game_id', 'self.content')"


      And posts.py is just an app which manages the forms. As I understand it, the User table was not created. However, I have run the db.create_all() command in the init file. Help would be appreciated!



      UPDATE: Now I have a new bug.



      sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: http://sqlalche.me/e/f405)


      For reference, this is my index.html file:



      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>DevlogIO</title>
      <link rel="stylesheet" href=" url_for('static', filename='style.css') ">
      </head>
      <body>
      <div id="container">
      <h1>Devlog IO</h1>
      <h2>Home</h2>
      <p>See the progress of your favorite developers, and discover new and rising game developers!</p>
      <div>
      <form action="" method="POST">
      form.hidden_tag()
      <fieldset>
      <legend>What was your progress for today?</legend>
      <div>
      form.gameSelect(class="")
      </div>
      <br>
      <div>
      form.title.label(class="")
      form.title(class="")
      </div>
      <br>
      <div>
      form.devLog.label(class="")
      form.devLog(class="")
      </div>
      <br>
      <div>
      form.submit(class="")
      </div>
      <br>
      </fieldset>
      </form>
      </div>
      <hr>
      <div id="stream">
      % for post in data.query.all() %
      <fieldset>
      <p><strong> post.title , form.gameSelect.data </strong></p>
      <p><i>by post.game_id </i></p>
      <p><i> post.date_posted </i></p>
      <p> post.content </p>
      </fieldset>
      <br>
      % endfor %
      </div>

      </div>

      <script src=" url_for('static', filename='script.js') "></script>
      </body>
      </html>






      python flask sqlalchemy flask-sqlalchemy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 13:48







      GM Crow

















      asked Nov 13 '18 at 13:15









      GM CrowGM Crow

      192




      192






















          1 Answer
          1






          active

          oldest

          votes


















          0














          in traceback in first line is said that error appears on line 11:
          from home import routes
          Your app even didn't get to db.create_all() and fails on import in which your references to db object that does ot exist yet.
          Try to put db.create_all() into routes.py






          share|improve this answer























          • This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

            – GM Crow
            Nov 13 '18 at 13:40










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281822%2fflask-sqlalchemy-app-fails-to-create-tables%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          in traceback in first line is said that error appears on line 11:
          from home import routes
          Your app even didn't get to db.create_all() and fails on import in which your references to db object that does ot exist yet.
          Try to put db.create_all() into routes.py






          share|improve this answer























          • This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

            – GM Crow
            Nov 13 '18 at 13:40















          0














          in traceback in first line is said that error appears on line 11:
          from home import routes
          Your app even didn't get to db.create_all() and fails on import in which your references to db object that does ot exist yet.
          Try to put db.create_all() into routes.py






          share|improve this answer























          • This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

            – GM Crow
            Nov 13 '18 at 13:40













          0












          0








          0







          in traceback in first line is said that error appears on line 11:
          from home import routes
          Your app even didn't get to db.create_all() and fails on import in which your references to db object that does ot exist yet.
          Try to put db.create_all() into routes.py






          share|improve this answer













          in traceback in first line is said that error appears on line 11:
          from home import routes
          Your app even didn't get to db.create_all() and fails on import in which your references to db object that does ot exist yet.
          Try to put db.create_all() into routes.py







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 13:27









          b111hb111h

          1




          1












          • This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

            – GM Crow
            Nov 13 '18 at 13:40

















          • This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

            – GM Crow
            Nov 13 '18 at 13:40
















          This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

          – GM Crow
          Nov 13 '18 at 13:40





          This seemed to do it.However, I now have an entirely new bug: sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140734986048960 and this is thread id 123145577107456 [SQL: 'SELECT post.id AS post_id, post.title AS post_title, post.date_posted AS post_date_posted, post.game_id AS post_game_id, post.content AS post_content nFROM post nWHERE ? = post.game_id'] [parameters: ['%(4536059552 param)s': 1]] (Background on this error at: sqlalche.me/e/f405)

          – GM Crow
          Nov 13 '18 at 13:40

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281822%2fflask-sqlalchemy-app-fails-to-create-tables%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          What does pagestruct do in Eviews?

          Dutch intervention in Lombok and Karangasem

          Channel Islands