I cannot connect to Hive database with the usage of Flask and SQLAlchemy. Below see my configuration in specific files:
.flaskenv file
DATABASE_URL="hive://<host>:10000/<db_name>"
config.py file
class ProductionConfig(Config):
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
SQLALCHEMY_ENGINE_OPTIONS = {connect_args={'auth': 'KERBEROS', 'kerberos_service_name': 'hive'}}
database.py file
import os
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
db = SQLAlchemy()
migrate = Migrate()
def register_db(app):
db.init_app(app)
migrate.init_app(app, db)
app.db = db
But when I try to run the application with flask db run or when I try to create migration script with the commnad flask db migrate I get the error [1] -> it seems that connection parameters are not sent into the engine correctly.
[1]
...
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 2263, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 104, in __init__
else engine.raw_connection()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 2370, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 2336, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/impl.py", line 241, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 440, in __init__
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 661, in __connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
with_traceback=exc_tb,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/dist-packages/pyhive/hive.py", line 94, in connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pyhive/hive.py", line 192, in __init__
self._transport.open()
File "/usr/local/lib/python3.6/dist-packages/thrift_sasl/__init__.py", line 96, in open
message=("Bad status: %d (%s)" % (status, payload)))
thrift.transport.TTransport.TTransportException: Bad status: 3 (b'Unsupported mechanism type PLAIN')
Python package versions:
alembic==1.4.3
Flask==1.1.2
Flask-Migrate==2.5.3
Flask-RESTful==0.3.8
Flask-SQLAlchemy==2.4.4
PyHive==0.6.2
python-dotenv==0.15.0
sasl==0.2.1
SQLAlchemy==1.3.20
ssh-import-id==5.7
thrift==0.13.0
thrift-sasl==0.4.2
Could anybody help me please?