Skip to content

Commit

Permalink
Removed unnecessary override from SQLite storage file
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 7, 2024
1 parent 25ec9f7 commit 2ad1ff0
Showing 1 changed file with 0 additions and 59 deletions.
59 changes: 0 additions & 59 deletions plaso/storage/sqlite/sqlite_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,65 +245,6 @@ def _SerializeAttributeContainer(self, container):

return serialized_string

def _WriteExistingAttributeContainer(self, container):
"""Writes an existing attribute container to the store.
The table for the container type is created if needed.
Args:
container (AttributeContainer): attribute container.
Raises:
IOError: when there is an error querying the storage file or if
an unsupported identifier is provided.
OSError: when there is an error querying the storage file or if
an unsupported identifier is provided.
"""
schema = self._GetAttributeContainerSchema(container.CONTAINER_TYPE)
if not schema:
raise IOError(
f'Unsupported attribute container type: {container.CONTAINER_TYPE:s}')

identifier = container.GetIdentifier()

self._CommitWriteCache(container.CONTAINER_TYPE)

column_names = []
values = []
for name, data_type in sorted(schema.items()):
attribute_value = getattr(container, name, None)
if attribute_value is not None:
if data_type == 'AttributeContainerIdentifier' and isinstance(
attribute_value, containers_interface.AttributeContainerIdentifier):
attribute_value = attribute_value.CopyToString()

elif data_type == 'bool':
attribute_value = int(attribute_value)

elif data_type not in self._CONTAINER_SCHEMA_TO_SQLITE_TYPE_MAPPINGS:
# TODO: add compression support
attribute_value = self._serializer.WriteSerialized(attribute_value)

column_names.append(f'{name:s} = ?')
values.append(attribute_value)

column_names = ', '.join(column_names)
query = (f'UPDATE {container.CONTAINER_TYPE:s} SET {column_names:s} '
f'WHERE _identifier = {identifier.sequence_number:d}')

if self._storage_profiler:
self._storage_profiler.StartTiming('write_existing')

try:
self._cursor.execute(query, values)

except (sqlite3.InterfaceError, sqlite3.OperationalError) as exception:
raise IOError(f'Unable to query storage file with error: {exception!s}')

finally:
if self._storage_profiler:
self._storage_profiler.StopTiming('write_existing')

def _WriteMetadata(self):
"""Writes metadata.
Expand Down

0 comments on commit 2ad1ff0

Please sign in to comment.