Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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