MCPcopy Create free account
hub / github.com/SEC-CAFE/sec.cafe / get_db_instance

Method get_db_instance

backend/src/utils/db.py:15–38  ·  view source on GitHub ↗
(db_config)

Source from the content-addressed store, hash-verified

13
14 @staticmethod
15 def get_db_instance(db_config):
16 if not RetryPostgresqlDatabase._instance:
17 RetryPostgresqlDatabase._instance = RetryPostgresqlDatabase(
18 db_config.get('database'),
19 host=db_config.get('host'),
20 user=db_config.get('user'),
21 password=db_config.get('password'),
22 port=db_config.get('port'),
23 max_connections=10,
24 autoconnect=True,
25 )
26 else:
27 if RetryPostgresqlDatabase._instance.database != db_config.get('database'):
28 RetryPostgresqlDatabase._instance = RetryPostgresqlDatabase(
29 db_config.get('database'),
30 host=db_config.get('host'),
31 user=db_config.get('user'),
32 password=db_config.get('password'),
33 port=db_config.get('port'),
34 max_connections=10,
35 autoconnect=True,
36 )
37
38 return RetryPostgresqlDatabase._instance
39
40
41def gen_db(db_config):

Callers 1

gen_dbFunction · 0.80

Calls 2

getMethod · 0.80

Tested by

no test coverage detected