Python Create Variable If Condition In Sql