1

i had a the following code:

from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()

class story(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    desc= db.Column(db.Text)

    def __init__(self, desc):
        self.desc= desc

and i created the db in a different file.

after the db table was created i needed to add another column to the db, so i added the following code to the "Text" class: name = db.Column(db.Text)

but when im running the project it output the following error:

OperationalError: (OperationalError) table story has no column named name

my question is: how can i change the db after it already been created?

1 Answer 1

1

You can use Alembic for "automatic" migrations

http://alembic.readthedocs.org/en/latest/

Or just add the new column to the database yourself

alter table STORY add column name ....

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.