You're doing it wrong
You want to start with calibredb list to get a list of all books and their ids,
calibredb list -f formats
Then iterate over the books, converting them, sending the converted output to a temp file ad add the temp file like this
calibredb add_format book_id tmpfile