eht16 / python-logstash-async

Python logging handler for sending log events asynchronously to Logstash.
MIT License
186 stars 51 forks source link

Retrieve non flushed event count in sqlite db at start #85

Closed cbeaujoin-stellar closed 1 year ago

cbeaujoin-stellar commented 1 year ago
  def _setup_database(self):
        if self._database_path:
           ...
            self._non_flushed_event_count = self._database.get_non_flushed_event_count()
    def get_non_flushed_event_count(self):
        query_fetch = '''SELECT count(*) FROM `event` WHERE `pending_delete` = 0;'''
        with self._connect() as connection:
            cursor = connection.cursor()
            cursor.execute(query_fetch)
            count = cursor.fetchone()[0]
        return count
eht16 commented 1 year ago

Implemented in master, thanks.