ValueError: too many values to unpack

I am following this flask tutorial. While learning about the database migration, I copied this code from the tutorial->

#!flask/bin/python
from migrate.versioning import api
from app import db
from config import SQLALCHEMY_DATABASE_URI  
from config import SQLALCHEMY_MIGRATE_REPO
v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
migration = SQLALCHEMY_MIGRATE_REPO + ('/versions/%03d_migration.py' % (v+1))
tmp_module = imp.new_module('old_model')
old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
exec(old_model, tmp_module.__dict__)
script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
open(migration, "wt").write(script)
api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
print('New migration saved as ' + migration)
print('Current database version: ' + str(v))

When I run this code, it showed me these errors->

Traceback (most recent call last):
  File "./db_migrate.py", line 12, in <module>
    script =api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata)
  File "<string>", line 2, in make_update_script_for_model
  File "/home/paladin/microblog/flask/local/lib/python2.7/site-packages/migrate/versioning/util/__init__.py", line 90, in catch_known_errors
    return f(*a, **kw)
  File "<string>", line 2, in make_update_script_for_model
  File "/home/paladin/microblog/flask/local/lib/python2.7/site-packages/migrate/versioning/util/__init__.py", line 160, in with_engine
    return f(*a, **kw)
  File "/home/paladin/microblog/flask/local/lib/python2.7/site-packages/migrate/versioning/api.py", line 321, in make_update_script_for_model
    engine, oldmodel, model, repository, **opts)
  File "/home/paladin/microblog/flask/local/lib/python2.7/site-packages/migrate/versioning/script/py.py", line 70, in make_update_script_for_model
    genmodel.ModelGenerator(diff,engine).genB2AMigration()
  File "/home/paladin/microblog/flask/local/lib/python2.7/site-packages/migrate/versioning/genmodel.py", line 219, in genB2AMigration
    for modelCol, databaseCol, modelDecl, databaseDecl in td.columns_different:
ValueError: too many values to unpack

Could anyone please tell me what these errors mean and how to resolve them?


Source: python

Leave a Reply