Python- sqlalchemy.exc.ArgumentError:could not assemble any primary key columns for mapped table -


i'm using flask + alembic + sqlalchemy. want create 2 table , use it. first, run alembic script :

"""add table insurace_bands , insurace_discounts  revision id: 39ba7ec3428 revises: 18468fbedbac create date: 2015-05-12 09:10:05.175513  """  # revision identifiers, used alembic. revision = '39ba7ec3428' down_revision = '18468fbedbac'  alembic import op import sqlalchemy sa  def upgrade():          op.create_table('insurance_bands',                  sa.column('id', sa.integer(), nullable=false),                  sa.column('name', sa.string(length=1024), nullable=false),                  sa.column('product_price', sa.numeric(precision=6, scale=2)),                  sa.column('monthly_price', sa.numeric(precision=6, scale=2)),                  sa.column('active', sa.boolean(), nullable=false, server_default='1'),                  sa.primarykeyconstraint('id')                 )      op.create_table('insurance_discounts',                  sa.column('id', sa.integer(), nullable=false),                  sa.column('name', sa.string(length=1024), nullable=false),                  sa.column('min_products', sa.integer()),                  sa.column('max_products', sa.integer()),                  sa.column('discount', sa.numeric(precision=6, scale=2)),                  sa.column('active', sa.boolean(), nullable=false, server_default='1'),                  sa.primarykeyconstraint('id')                 )  def downgrade():      op.drop_table(     'insurance_bands'     )       op.drop_table(     'insurance_discounts'     ) 

this script run ok. then, create 2 models this:

# -*- coding: utf-8 -*- """     admin.insurance_brands.models     ~~~~~~~~~~~~~~~~~~~~~      insurance brand models """  ..core import db ..helpers import jsonserializer   class insurancebandjsonserializer(jsonserializer):     __json_public__ = ['id', 'name', 'product_price', 'monthly_price', 'active']   class insuranceband(insurancebandjsonserializer, db.model):      __tablename__ = 'insurance_bands'      id = db.column(db.integer(), primary_key=true),     name = db.column(db.unicode(1024)),     product_price = db.column(db.numeric(precision=6, scale=2)),     monthly_price = db.column(db.numeric(precision=6, scale=2)),     active = db.column(db.boolean, default=true)   class insurancediscountjsonserializer(jsonserializer):     __json_public__ = ['id', 'name', 'min_products', 'max_products', 'active']   class insurancediscount(insurancediscountjsonserializer, db.model):      __tablename__ = 'insurance_discounts'      id = db.column(db.integer(), primary_key=true),     name = db.column(db.unicode(1024)),     min_products = db.column(db.integer()),     max_products = db.column(db.integer()),     active = db.column(db.boolean, default=true) 

but when run server: python wsgi.py, throws error:

sqlalchemy.exc.argumenterror: mapper mapper|insuranceband|insurance_bands not assemble primary key columns mapped table 'insurance_bands'

it seem model doesn't have primary key defined it.

can me. in advance.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -