<div dir="ltr">In an answer yesterday I learned that I can use DB Manager via Python to work with my PostGIS database. <div><br></div><div>Within the Processing framework, I need to get a reference to a database based on an input layer. In the past, I could accomplish this by parsing the layer's URI. However, it appears that DB Manager refers to databases using the DB's connection name as given in QGIS. How can I refer to my database from one of its tables that exists as a layer in QGIS?</div><div><br></div><div>Here's an example:</div><div><br></div><div>Table name: foo</div><div>Database name in PostgreSQL: bar</div><div>Connection name in QGIS: baz</div><div><br></div><div>I need to get "baz" based on a QGIS layer that points to "foo".</div><div><br></div><div>Thanks for any help!</div></div>