Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我应该如何基于另一个类创建SQLAlchemy模型?_Python_Sqlalchemy - Fatal编程技术网

Python 我应该如何基于另一个类创建SQLAlchemy模型?

Python 我应该如何基于另一个类创建SQLAlchemy模型?,python,sqlalchemy,Python,Sqlalchemy,我有一个常规类一些东西,基本上只包含一些字段。我需要制作一个SQLAlchemy模型SomethingModel(在ORM中),它表示一个类似Something的对象,并带有几个额外的字段(例如主键)。最好的方法是什么 到目前为止,我一直想让SomethingModel继承SomethingModel,但我现在使用的是多重继承,我听说这是不好的(SomethingModel将继承somethingmode和SQLAlchemy的Base)。我还认为我可以简单地从SomethingModel.\u

我有一个常规类
一些东西
,基本上只包含一些字段。我需要制作一个SQLAlchemy模型
SomethingModel
(在ORM中),它表示一个类似
Something
的对象,并带有几个额外的字段(例如主键)。最好的方法是什么

到目前为止,我一直想让
SomethingModel
继承
SomethingModel
,但我现在使用的是多重继承,我听说这是不好的(
SomethingModel
将继承
somethingmode
和SQLAlchemy的
Base
)。我还认为我可以简单地从
SomethingModel.\uuuuu init\uuuuu
内部调用
SomethingModel.\uuuuu init\uuuu
-这样会更好吗

我知道我仍然需要SQLAlchemy的列字段来保存
SomethingModel
中的
SomethingModel
字段。这似乎也让事情变得有点混乱

实现这一目标的“最佳”方法是什么?

在课堂上使用