title: How to make a get_or_create using OR with SQLAlchemy?
body: <p>I have a get or create method that works well, but it <code>AND</code>s the arguments, using <code>filter_by</code>. I want the same thing, but using or, similar to:</p>
  
  <pre><code>def get_or_create_or(cls, session, **kwargs):
      instance = session.query(cls).filter(or_(**kwargs)).first()
      if instance:
          return instance
      else:
          instance = cls(**kwargs)
          return instance
  </code></pre>
  
  <p>This doesn't work because or_ doesn't expect keyword arguments. How can I make a generalized version of this?</p>
  
  <p>For example, the current get_or_create I have can take in a phone and an email, and will return a row that matches both. I want to be able to pass in a phone and an email and get a row that matches either.</p>