MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / get_db_connection

Function get_db_connection

web/regression/python_test_utils/test_utils.py:53–78  ·  view source on GitHub ↗

This function returns the connection object of psycopg

(db, username, password, host, port, sslmode="prefer",
                      max_connections=None)

Source from the content-addressed store, hash-verified

51
52
53def get_db_connection(db, username, password, host, port, sslmode="prefer",
54 max_connections=None):
55 """This function returns the connection object of psycopg"""
56 if max_connections:
57 with psycopg.connect(
58 dbname=db,
59 user=username,
60 password=password,
61 host=host,
62 port=port,
63 sslmode=sslmode,
64 autocommit=True,
65 ) as conn:
66 cur = conn.cursor()
67 cur.execute('ALTER SYSTEM SET max_connections TO 100;')
68 cur.execute('SELECT pg_reload_conf();')
69
70 connection = psycopg.connect(
71 dbname=db,
72 user=username,
73 password=password,
74 host=host,
75 port=port,
76 sslmode=sslmode
77 )
78 return connection
79
80
81def get_server_version(connection):

Callers 15

create_languageFunction · 0.90
verify_languageFunction · 0.90
delete_languageFunction · 0.90
create_event_triggerFunction · 0.90
verify_event_triggerFunction · 0.90
create_extensionFunction · 0.90
verify_extensionFunction · 0.90
drop_extensionFunction · 0.90
create_fdwFunction · 0.90
verify_fdwFunction · 0.90
delete_fdwFunction · 0.90

Calls 2

connectMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected