def saveIfNotExists(cls, dev_nonce, device_id, packet_id): existing_dev_nonces = session.query(DevNonce).filter(DevNonce.dev_nonce == dev_nonce).filter(DevNonce.device_id == device_id).all() if len(existing_dev_nonces): prev_packet_id = existing_dev_nonces[0].packet_id existing_dev_nonces[0].packet_id = packet_id return prev_packet_id else: DevNonce( dev_nonce = dev_nonce, device_id = device_id, packet_id = packet_id ).save() session.flush() return None
def save(self): session.add(self) session.flush() session.commit()
def save(self): session.add(self) session.flush()
def save_and_flush(self): session.add(self) session.flush()
def save_to_db(self): session.add(self) session.flush()