def session(self): if self._engine is None: raise DatastoreConnectionError("Need to call setup_connection() first") if self._session is None: session_factory = sessionmaker(bind=self._engine) self._session = scoped_session(session_factory) return self._session
def list_records(self): try: return list(IntegerSequencedRecord.objects.all()) except (CQLEngineException, NoHostAvailable) as e: raise DatastoreConnectionError(e) except InvalidRequest as e: raise DatastoreTableError(e)
def create_record(self): record = CqlIntegerSequencedItem(s=uuid4(), p=0, t='topic', d='{}') try: record.save() except (CQLEngineException, NoHostAvailable) as e: raise DatastoreConnectionError(e) except InvalidRequest as e: raise DatastoreTableError(e) return record
def create_record(self): record = IntegerSequencedRecord(sequence_id=uuid4(), position=0, topic="topic", state=b"{}") try: record.save() except (CQLEngineException, NoHostAvailable) as e: raise DatastoreConnectionError(e) except InvalidRequest as e: raise DatastoreTableError(e) return record