Git Product home page Git Product logo

Comments (3)

bprinty avatar bprinty commented on August 27, 2024

I was able to reproduce this issue when database tables hadn't been created before trying to commit date. The no such table: transaction is a bit of a red herring - if you weren't using Flask-Continuum, I think you'd see an error like "no such table: articles". Here is what you can try to resolve the issue:

$ flask shell
>>> from app import db, Article
>>> db.create_all()
>>> article = Article(name='Some article', content='Some content') 
>>> db.session.add(article)
>>> db.session.commit()

In general, you'll want to make sure db.create_all() has been run before you start using a database in the application.

from flask-continuum.

bprinty avatar bprinty commented on August 27, 2024

Also, I've added this and the previous ticket to a Troubleshooting section of the documentation. I'll keep updating that section as new problems come up. Thanks for the input!

from flask-continuum.

josipbudzaki avatar josipbudzaki commented on August 27, 2024

I've had a similar problem: transaction and version tables were not created. After fiddling around I found out that in my configuration, I have to run db.create_all() twice.

  1. db.create_all(app=create_app()) with context
  2. db.create_all()

For reference, here's the whole code:

from flask import Flask
from flask_continuum import Continuum, VersioningMixin
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()
continuum = Continuum(db=db)


class Article(db.Model, VersioningMixin):
    __tablename__ = 'article'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.Unicode(255))
    content = db.Column(db.UnicodeText)

def make_article():
    article = Article(name='Some article', content='Some content')
    db.session.add(article)
    db.session.commit()


def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////database.db'
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    db.init_app(app)
    app.app_context().push()
    continuum.init_app(app)
    
    return app


if __name__ == '__main__':
    db.create_all(app=create_app())
    db.create_all()

from flask-continuum.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.