Comments (3)
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.
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.
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.
db.create_all(app=create_app())
with contextdb.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)
- Finish usage documentation for plugin
- using flask-migrate HOT 1
- Make flask-continuum depend on sqlalchemy_continuum HOT 1
- Setting up the flask application with extensions Python 3.10.6 Issue HOT 1
- Finish tests for plugin (including tests for versioningmixin properties)
- Clean up package and release
- Create logo and banner image for plugin
- Add support for native versioning via configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-continuum.