Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/85.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_Sql_Sqlalchemy - Fatal编程技术网

Python Sqlalchemy检查对列计数的约束

Python Sqlalchemy检查对列计数的约束,python,sql,sqlalchemy,Python,Sql,Sqlalchemy,我在sqlalchemy中有一张桌子: class Table(Model): __table_name__ = 'tbl' col1 = Column(Integer) col2 = Column(Integer) 我想将此约束添加到我的模型: check ( count ( select * from tbl t1, tbl t2 where t1.clo2=t2.col2) < 3) 我将此查询置于Ch

我在sqlalchemy中有一张桌子:

class Table(Model):
  __table_name__ = 'tbl'
  col1 = Column(Integer)
  col2 = Column(Integer)
我想将此约束添加到我的模型:

check ( count ( select * 
                from tbl t1, tbl t2
                where t1.clo2=t2.col2) < 3)

我将此查询置于CheckConstraint中,但不起作用。

什么是m1,m2?你是说t1,t2?还有,你不需要用tbl作为t1?是的。我编辑了那个错误