Python If Logical Operators In Sql