flask-migrate

Could not assemble any primary key columns for mapped table

半城伤御伤魂 提交于 2019-11-30 10:48:18
When I'm trying to create a database schema migration, I'm getting this weird error. Can you please help me to figure out what's wrong? $ python app.py db upgrade [skipped] sqlalchemy.exc.ArgumentError: Mapper Mapper|EssayStateAssociations|essay_associations could not assemble any primary key columns for mapped table 'essay_associations' My model: class EssayStateAssociations(db.Model): __tablename__ = 'essay_associations' application_essay_id = db.Column( db.Integer, db.ForeignKey("application_essay.id"), primary_key=True), theme_essay_id = db.Column( db.Integer, db.ForeignKey("theme_essay.id

Flask-Migrate not creating tables

痴心易碎 提交于 2019-11-30 08:09:56
I have the following models in file listpull/models.py : from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id = db.Column(db.Integer, db.ForeignKey('list_type.id'), nullable=False) list_type = db.relationship('ListType', backref=db.backref('jobs', lazy='dynamic')) record_count = db.Column(db.Integer, nullable=False) status = db.Column(db.Integer, nullable=False) sf_job_id = db.Column(db.Integer, nullable=False) created_at = db.Column(db.DateTime, nullable=False) compressed_csv = db.Column(db.LargeBinary) def __init

Creating seed data in a flask-migrate or alembic migration

╄→尐↘猪︶ㄣ 提交于 2019-11-29 19:26:17
How can I insert some seed data in my first migration? If the migration is not the best place for this, then what is the best practice? """empty message Revision ID: 384cfaaaa0be Revises: None Create Date: 2013-10-11 16:36:34.696069 """ # revision identifiers, used by Alembic. revision = '384cfaaaa0be' down_revision = None from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('list_type', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=80), nullable=False), sa

Could not assemble any primary key columns for mapped table

◇◆丶佛笑我妖孽 提交于 2019-11-29 15:56:22
问题 When I'm trying to create a database schema migration, I'm getting this weird error. Can you please help me to figure out what's wrong? $ python app.py db upgrade [skipped] sqlalchemy.exc.ArgumentError: Mapper Mapper|EssayStateAssociations|essay_associations could not assemble any primary key columns for mapped table 'essay_associations' My model: class EssayStateAssociations(db.Model): __tablename__ = 'essay_associations' application_essay_id = db.Column( db.Integer, db.ForeignKey(

Flask-Migrate not creating tables

爱⌒轻易说出口 提交于 2019-11-29 11:06:21
问题 I have the following models in file listpull/models.py : from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id = db.Column(db.Integer, db.ForeignKey('list_type.id'), nullable=False) list_type = db.relationship('ListType', backref=db.backref('jobs', lazy='dynamic')) record_count = db.Column(db.Integer, nullable=False) status = db.Column(db.Integer, nullable=False) sf_job_id = db.Column(db.Integer, nullable=False)

How do I split Flask models out of app.py without passing db object all over?

烂漫一生 提交于 2019-11-29 04:09:47
I'd like to use Flask-Migrate and am looking at their example: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' db = SQLAlchemy(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) class User(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(128)) if __name__ == '__main__': manager.run() This works great as a simple play example,

Creating seed data in a flask-migrate or alembic migration

我的未来我决定 提交于 2019-11-28 15:49:24
问题 How can I insert some seed data in my first migration? If the migration is not the best place for this, then what is the best practice? """empty message Revision ID: 384cfaaaa0be Revises: None Create Date: 2013-10-11 16:36:34.696069 """ # revision identifiers, used by Alembic. revision = '384cfaaaa0be' down_revision = None from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('list_type', sa.Column('id', sa

How do I split Flask models out of app.py without passing db object all over?

拟墨画扇 提交于 2019-11-27 22:16:39
问题 I'd like to use Flask-Migrate and am looking at their example: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db' db = SQLAlchemy(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) class User(db.Model): id = db.Column(db.Integer, primary_key=True) name = db