将列添加到 SQLAlchemy 表 [英] add column to SQLAlchemy Table

查看:64
本文介绍了将列添加到 SQLAlchemy 表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SQLAlchemy 创建了一个表,但忘记添加一列.我基本上想这样做:

I made a table using SQLAlchemy and forgot to add a column. I basically want to do this:

users.addColumn('user_id', ForeignKey('users.user_id'))

这是什么语法?我在文档中找不到它.

What's the syntax for this? I couldn't find it in the docs.

推荐答案

这称为数据库迁移(SQLAlchemy 不支持开箱即用的迁移).您可以考虑使用 sqlalchemy-migrate 来帮助解决这些情况,或者您可以通过您选择的数据库的命令行实用程序ALTER TABLE

This is referred to as database migration (SQLAlchemy doesn't support migration out of the box). You can look at using sqlalchemy-migrate to help in these kinds of situations, or you can just ALTER TABLE through your chosen database's command line utility,

这篇关于将列添加到 SQLAlchemy 表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆