I have an instance of a Connection (required to DB API 2.0-compliant), but I don’t have the module from which it was imported. The problem is that I am trying to use named parameters, but I don’t know which paramstyle to use.
Since paramstyle is a module-level constant, I can’t just ask the Connection. I tried using inspect.getmodule() on my Connection instance, but it just returned None. Is there an easier way that I’m just missing, or will I need to do some try/except code to determine which paramstyle to use?
Pass
type(connection)(connection class) toinspect.getmodule(), not connection object. The class tracks the module it was defined in soinspectcan find it, while object creation is not tracked.