21bb97866ed8_added_chapter_and_section_to_exercises.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:research-eGrader 作者: openstax 项目源码 文件源码
def upgrade():
    bind = op.get_bind()
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('exercises', sa.Column('chapter_id', sa.Integer(), nullable=True))
    op.add_column('exercises', sa.Column('section_id', sa.Integer(), nullable=True))
    op.add_column('exercises', sa.Column('book_row_id', sa.Integer(), nullable=True))

    op.add_column('subjects', sa.Column('book_url', sa.String(), nullable=True))
    ### end Alembic commands ###

    data = [
        {'id': 1, 'book_url': 'https://staging-tutor.cnx.org/contents/d52e93f4-8653-4273-86da-3850001c0786'},
        {'id': 2, 'book_url': 'https://staging-tutor.cnx.org/contents/334f8b61-30eb-4475-8e05-5260a4866b4b'}
    ]

    for item in data:
        update = sa.update(subject_table)\
            .where(subject_table.c.id == item['id'])\
            .values(dict(book_url=item['book_url']))
        bind.execute(update)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号