Sqlachemy的警告SAWarning: The IN-predicate on "sns_object.BIZ_ID" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate.
On to in The with ID quot object
2023-09-14 09:06:37 时间
我在使用db_session.query,查询的时候idlist是个空值时候,执行下面的语句就会出现警告。
其中后面delete(synchronize_session=False)是删除前面的一堆查询相当于查出符合条件的数据。
synchronize_session用于query在进行delete or update操作时,对session的同步策略。False - 不对session进行同步,直接进行delete or update操作。
db_session.query(CommentInfo).filter(CommentInfo.BIZ_ID.in_(idlist)).filter(CommentInfo.MEDIA_TYPE=="INS").delete(synchronize_session=False)
def delete_exist_bizid(self,dics): idlist=dics.get("BIZ_ID") db_session.query(CommentInfo).filter(CommentInfo.BIZ_ID.in_(idlist)).filter(CommentInfo.MEDIA_TYPE=="INS").delete(synchronize_session=False) db_session.commit()
if __name__=="__main__": dics={"BIZ_ID":[]} SaveData().delete_exist_bizid(dics)
解决方案:加一个判断条件当BIZ_ID的值不为空的时候,才进行后面删除操作。
相关文章
- maven报 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(defalut-compile) on project 项目名称:No such compile 'javac'
- 服务器磁盘扩展卷时遭遇“There is not enough space available on the disk(s) to complete this operation.”错误
- Write on ……… failed: 112(failed to retrieve text for this error. Reason: 15105)
- ArcGIS Server启动服务报:ERROR: Unable to start Xvfb on any port in the range 6600 - 6619
- [Javascript] Broadcaster + Operator + Listener pattern -- 14. Marking Done Based on a Condition
- [PWA] Add Push Notifications to a PWA with React in Chrome and on Android
- [AngularJS] Using an AngularJS directive to hide the keyboard on submit
- 解决org.openqa.selenium.WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms org.springframework.beans.BeanInstantiation
- [PWA] Add Push Notifications to a PWA with React in Chrome and on Android
- [Javascript] Limit Built Branches on Travis
- how to extend a SAPUI5 Fiori application on both view and controller in WebIDE
- how to extend a SAPUI5 Fiori application on both view and controller in WebIDE
- how to setup a Kubernetes cluster on GCP
- Android报错提示Attempt to invoke interface method ‘int java.util.List.size()‘ on a null object reference
- 成功解决ImportError: [joblib] Attempting to do parallel computing without protecting your import on a sy
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)
- MySQL远程连接报错2003-cant connection to mysql server on ‘IP’(10061 unknown error)
- How to create DB2 Instance on Linux
- 【Transformer】9、CrossFormer:A versatile vision transformer based on cross-scale attention