Thanks, kovidgoyal. But I was looking at the file, and the AddAction class, and I can't find what I am looking for (or maybe I don't know what's exactly the thing I'm looking for).
I was looking at library/cli.py for adding, deleting and updating format books, and using the same objetcs and functions the command line uses for this. It works OK, but I don't know how to refresh the main library window. When I update a book (removing old format and adding a new one), or I update metadata, it refresh correctly. But when I add a book, or remove it, it doesn't.
Maybe db.add_books() and db.delete_books() are not the functions I need to use?