I don’t know enough to conduct the process through side databases but you can put the python code into this loop to open the dwgs and run the code on each one. (Make sure you are using ironpython)
Just pass in a list of DWG paths. Example → [“F:\Projects\1750\site.dwg”, “F:\Projects\1750\base.dwg”]
You can collect the dwg paths in a directory with the os module: Python - List Files in a Directory - GeeksforGeeks
You can also use python to filter out files that aren’t “.dwgs”.
I think this thread has a ton of really good information regarding iterating through dwgs with python: Rename XREFs in multiple dwgs - #50 by WrightEngineering
If you download that .dyn it should have plenty of code in there that you can take and use.
@jacob.small also has a really good zoom recording further up on that thread that provides a good example of the process of creating a python script to iterate through multiple dwgs.
for DWGPath in DWGPaths:
    adoc = DocumentCollectionExtension.Open(acapp.DocumentManager, DWGPath, False)
    with adoc.LockDocument():
        with adoc.Database as db:
            with db.TransactionManager.StartTransaction() as t:
                #INSERT CODE HERE
                t.Commit()
                pass
                
    if adoc:
        DocumentExtension.CloseAndSave(adoc, DWGPath)