用Flask + SqlAlchemy创建一个表 [英] Create only ONE table with Flask + SqlAlchemy

查看:382
本文介绍了用Flask + SqlAlchemy创建一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于MySQL DBMS的Web应用程序
我跟着那个答案的教程它会创建与调用 create_all()的每个模型相关的所有表。

I'm developing a web application based on MySQL DBMS I followed the tutorial in that answer in which it creates all the tables related to every model calling the create_all().

我唯一不理解的是如何只创建一个表,而不是全部。我通过谷歌搜索,但无法找到答案。

The only one thing I don't understand is how to create only one table and not all of them. I searched through google but can't find an answer.

推荐答案

您可以使用 create 方法

you can use create method

Model.__table__.create(session.bind)

这篇关于用Flask + SqlAlchemy创建一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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