this is my database.py
engine = create_engine('sqlite:///:memory:', echo=True) session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine)) Base = declarative_base() Base.query = session.query_property() def init_db():
and this is my backend.py
from flask import Flask, session, g, request, render_template from database import init_db, session from models import * app = Flask(__name__) app.debug = True app.config.from_object(__name__)
I notice a couple of strange things:
- When I do
python backend.py , I see that tables are created twice . The same create table commands run - When I visit '/', I get the following error, even if I am 100% sure that the tables are created. Why?
cursor.execute (operator, parameters) OperationalError: (OperationalError) no such table: users u'INSERT INTO users DEFAULT VALUES '()
source share