I'm looking for the fastest way to create a new SQLAlchemy object only if it doesn't already exist in the database.
The way I'm doing it now is by first getting the count of the query to see if it exists, and if not--then I create it. EG:
if not User.query.filter(email=user.email).count():
db.session.add(user)
db.session.commit()
Is this the best way to do it? Would love some feedback. Thanks!