peewee - Python's ORM queries the database. If no results are found, an error will be reported?
迷茫
迷茫 2017-05-18 10:57:01
0
2
1059

I am using peewee, and I found that when querying a piece of data, I use the get method. If there is no matching data in the database, a DoesNotExist error will be thrown directly. I really can't stand this kind of framework that throws errors at every turn. Because I wrote a global error capture, I always automatically enter the global error capture method. You have to be forced to manually write try to nest. Sometimes there are too many queries and you have to nest several levels of try.

I just want to ask, is there any ORM framework like Java or C# that returns null if the query cannot find the result? Is it possible to encapsulate it yourself?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
迷茫

SQLAlchemy

PHPzhong
# SQLAlchemy
city = sesion.query(User.city).filter(User.name=="Hello").one()

If city is null, and this query returns None (null) instead of throwing an exception, does this record exist or not?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!