After resetting my Windows, how can I keep the database?

If you can, reserve a separate hard disk (or hard disk partition) for Plex’s own data.
That way it will survive even a full reformatting of the system drive/partition.
Here is a guide how Moving Metadata on Windows

If you have ‘managed’ users or have shared your server with other people, save the contents of the Plex branch in the Windows registry as well https://support.plex.tv/articles/201539237-backing-up-plex-media-server-data/