Skip to content

Commit

Permalink
more informative ImportError message
Browse files Browse the repository at this point in the history
  • Loading branch information
naoyak committed Sep 11, 2018
1 parent 6058a94 commit c4f42f2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions omniduct/databases/hiveserver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ def _init(self, schema=None, driver='pyhive', auth_mechanism='NOSASL',
def _connect(self):
from sqlalchemy import create_engine, MetaData
if self.driver == 'pyhive':
import pyhive.hive
try:
import pyhive.hive
except ImportError:
raise ImportError("""
Omniduct is attempting to use the 'pyhive' driver, but it
is not installed. Please either install the pyhive package,
or reconfigure this Duct to use the 'impyla' driver.
""")
self.__hive = pyhive.hive.connect(host=self.host,
port=self.port,
auth=self.auth_mechanism,
Expand All @@ -100,7 +107,11 @@ def _connect(self):
try:
import impala.dbapi
except ImportError:
raise ImportError("Please install impyla or specify driver='pyhive'.")
raise ImportError("""
Omniduct is attempting to use the 'impyla' driver, but it
is not installed. Please either install the impyla package,
or reconfigure this Duct to use the 'pyhive' driver.
""")
self.__hive = impala.dbapi.connect(host=self.host,
port=self.port,
auth_mechanism=self.auth_mechanism,
Expand Down

0 comments on commit c4f42f2

Please sign in to comment.