'Can I make a dict of connections to database?

I need to parse some db info from yml file and iteratively create several connections. The problem is - how to store them? Can I make a dict of connections?

for example:

for k,v in dbs_info.items():
   connections[k] = dbclass(v) # here we create engine

I need something like this to address to connections

conn = {'db1': conn1,'db2':conn2}


Solution 1:[1]

DICT like you suggested as "conn" should work.

conn['db1'] value is the connection module (session).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Avner Cohen