Reputation: 25
I have this raw mysql query, SELECT user_id FROM user WHERE email_address NOT REGEXP '[^@]+@[^@]+\.[^@]+'
, this filters all email addresses having invalid email addresses.
I will need an SQLAlchemy equivalent for this.
I have tried this query, User.query.filter(User.email_address.op('regexp')(r'[^@]+@[^@]+\.[^@]+')).all()
, but it filters all the valid email addresses. I just need to know how to add the NOT
in this query.
Upvotes: 2
Views: 2373
Reputation: 361
try this:
User.query.filter(User.email_address.op('not regexp')(r'[^@]+@[^@]+\.[^@]+')).all()
Upvotes: 2