code: def attach(self, path, encoding='utf-8'):
          
          if self.is_attached():
              raise ItsdbError('already attached at {}'.format(self.path))
  
          try:
              path = _table_filename(path)
          except ItsdbError:
              # neither path nor path.gz exist; create new empty file
              # (note: if the file were non-empty this would be destructive)
              path = _normalize_table_path(path)
              open(path, 'w').close()
          else:
              # path or path.gz exists; check if merging would be a problem
              if os.stat(path).st_size > 0 and len(self._records) > 0:
                  raise ItsdbError(
                      'cannot attach non-empty table to non-empty file')
  
          self.path = path
          self.encoding = encoding
  
          # if _records is not empty then we're attaching to an empty file
          if len(self._records) == 0:
              self._sync_with_file()
docs: Attach the Table to the file at *path*.
  
          Attaching a table to a file means that only changed records
          are stored in memory, which greatly reduces the memory
          footprint of large profiles at some cost of
          performance. Tables created from :meth:`Table.from_file()` or
          from an attached :class:`TestSuite` are automatically
          attached. Attaching a file does not immediately flush the
          contents to disk; after attaching the table must be separately
          written to commit the in-memory data.
  
          A non-empty table will fail to attach to a non-empty file to
          avoid data loss when merging the contents. In this case, you
          may delete or clear the file, clear the table, or attach to
          another file.
  
          Args:
              path: the path to the table file
              encoding: the character encoding of the files in the testsuite