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

Function get_db_server

web/regression/python_test_utils/test_utils.py:802–832  ·  view source on GitHub ↗

This function returns the SQLite database connection :param sid: server id :type sid: int :return: db connection

(sid)

Source from the content-addressed store, hash-verified

800
801
802def get_db_server(sid):
803 """
804 This function returns the SQLite database connection
805 :param sid: server id
806 :type sid: int
807 :return: db connection
808 """
809 connection = ''
810 conn = sqlite3.connect(config.TEST_SQLITE_PATH)
811 cur = conn.cursor()
812 server = cur.execute(
813 'SELECT name, host, port, maintenance_db,'
814 ' username FROM server where id=%s' % sid
815 )
816 server = server.fetchone()
817 if server:
818 name = server[0]
819 host = server[1]
820 db_port = server[2]
821 db_name = server[3]
822 username = server[4]
823 config_servers = test_setup.config_data['server_credentials']
824 # Get the db password from config file for appropriate server
825 db_password = get_db_password(config_servers, name, host, db_port)
826 if db_password:
827 # Drop database
828 connection = get_db_connection(
829 db_name, username, db_password, host, db_port
830 )
831 conn.close()
832 return connection
833
834
835def configure_preferences(default_binary_path=None):

Callers 1

_cleanupFunction · 0.85

Calls 6

get_db_passwordFunction · 0.85
get_db_connectionFunction · 0.85
connectMethod · 0.45
executeMethod · 0.45
fetchoneMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected