code: def get_or_connect(cls, **kwargs):
          
          try:
              inst = cls.get(**kwargs)
              created = False
          except DoesNotExist:
              inst = cls(**kwargs)
              created = True
          except Exception:
              raise
          return inst, created
docs: Try to retrieve an object in db, and create it if it does not exist.