MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / add_extension

Function add_extension

web/pgadmin/tools/debugger/tests/utils.py:57–95  ·  view source on GitHub ↗
(self, utils, del_function=True, db_utils=None)

Source from the content-addressed store, hash-verified

55
56
57def add_extension(self, utils, del_function=True, db_utils=None):
58 extension_url = '/browser/extension/obj/{0}/{1}/{2}/'.format(
59 str(utils.SERVER_GROUP), str(self.server_id), str(self.db_id))
60 extension_data = {
61 "name": "pldbgapi",
62 "relocatable": True,
63 "schema": self.schema_name,
64 "version": "1.1"
65 }
66 try:
67 connection = utils.get_db_connection(self.db_name,
68 self.server['username'],
69 self.server['db_password'],
70 self.server['host'],
71 self.server['port'],
72 self.server['sslmode'])
73 pg_cursor = connection.cursor()
74 # Drop existing extension.
75 pg_cursor.execute('''DROP EXTENSION IF EXISTS "%s" ''' % 'pldbgapi')
76
77 # Create pldbgapi extension if not exist.
78 pg_cursor.execute('''CREATE EXTENSION IF NOT EXISTS
79 "%s" WITH SCHEMA "%s" VERSION
80 "%s" ''' % ('pldbgapi', self.schema_name, '1.1')
81 )
82
83 connection.commit()
84 connection.close()
85 except Exception as e:
86 print(
87 "============================================================="
88 "=========\n",
89 file=sys.stderr
90 )
91 if del_function:
92 delete_function(self, utils)
93 connection.close()
94 db_utils.disconnect_database(self, self.server_id, self.db_id)
95 self.skipTest('The debugger plugin is not installed.')
96
97
98def init_debugger_function(self):

Callers

nothing calls this directly

Calls 4

delete_functionFunction · 0.85
get_db_connectionMethod · 0.80
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected