MCPcopy Create free account
hub / github.com/apache/impala / PostgresqlConnection

Class PostgresqlConnection

tests/comparison/db_connection.py:1034–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032
1033
1034class PostgresqlConnection(DbConnection):
1035
1036 PORT = 5432
1037 USER_NAME = "postgres"
1038
1039 _DB_TYPE = POSTGRESQL
1040 _CURSOR_CLASS = PostgresqlCursor
1041
1042 @property
1043 def supports_kill(self):
1044 return True
1045
1046 def kill(self):
1047 self._conn.cancel()
1048
1049 def _connect(self):
1050 try:
1051 import psycopg2
1052 except ImportError as e:
1053 if "No module named psycopg2" not in str(e):
1054 raise e
1055 import os
1056 import subprocess
1057 from tests.util.shell_util import shell
1058 LOG.info("psycopg2 module not found; attempting to install it...")
1059 pip_path = os.path.join(os.environ["IMPALA_HOME"], "infra", "python", "env",
1060 "bin", "pip")
1061 try:
1062 shell(pip_path + " install psycopg2", stdout=subprocess.PIPE,
1063 stderr=subprocess.STDOUT)
1064 LOG.info("psycopg2 installation complete.")
1065 except Exception as e:
1066 LOG.error("psycopg2 installation failed. Try installing python-dev and"
1067 " libpq-dev then try again.")
1068 raise e
1069 import psycopg2
1070 self._conn = psycopg2.connect(
1071 host=self._host_name,
1072 port=self._port,
1073 user=self._user_name,
1074 password=self._password,
1075 database=self.db_name)
1076 self._conn.autocommit = True
1077
1078
1079class MySQLConnection(DbConnection):

Callers 2

prepareMethod · 0.90
postgresql_cursorFunction · 0.90

Calls

no outgoing calls

Tested by 1

postgresql_cursorFunction · 0.72