使用 presto-python-client 的用户名和密码
username & password with presto-python-client
我正在尝试更换
jaydebeapi 与 facebook 的 presto-python-client
问题是如何替换认证位
db = jaydebeapi.connect(connection['jclass'], connection['host'],[ connection['user'], connection['pass']], connection['jar'])
使用 presto-python-client
import prestodb
conn= prestodb.dbapi.connect(
host='localhost',
port=8080,
user='the-user',
catalog='the-catalog',
schema='the-schema',
isolation_level=transaction.IsolationLevel.REPEATABLE_READ,
)
而且我找不到任何地方来指定如何传递密码。
进行此更改的原因是我在尝试使用 jaydebeapi
传递长查询(18k 个字符)时遇到了不明确的错误
我们最终使用了 SQLAlchemy,所以解决方案是
from sqlalchemy.engine import create_engine
engine = create_engine('presto://{0}:{1}@{2}:{3}/hive'.format(connection['user'],connection['pass'],connection['host'],int(connection['port'])), connect_args={'protocol': 'https', 'requests_kwargs': {'verify': False}})
db = engine.raw_connection()
现在旧方法已被弃用,所以这是连接到 presto 的新方法
cursor = presto.connect(presto_host,
presto_port,
requests_kwargs={'auth': HTTPBasicAuth(presto_username, presto_password)},
poll_interval=1,
protocol='https',
source='pyhive').cursor()
我正在尝试更换 jaydebeapi 与 facebook 的 presto-python-client 问题是如何替换认证位
db = jaydebeapi.connect(connection['jclass'], connection['host'],[ connection['user'], connection['pass']], connection['jar'])
使用 presto-python-client
import prestodb
conn= prestodb.dbapi.connect(
host='localhost',
port=8080,
user='the-user',
catalog='the-catalog',
schema='the-schema',
isolation_level=transaction.IsolationLevel.REPEATABLE_READ,
)
而且我找不到任何地方来指定如何传递密码。 进行此更改的原因是我在尝试使用 jaydebeapi
传递长查询(18k 个字符)时遇到了不明确的错误我们最终使用了 SQLAlchemy,所以解决方案是
from sqlalchemy.engine import create_engine
engine = create_engine('presto://{0}:{1}@{2}:{3}/hive'.format(connection['user'],connection['pass'],connection['host'],int(connection['port'])), connect_args={'protocol': 'https', 'requests_kwargs': {'verify': False}})
db = engine.raw_connection()
现在旧方法已被弃用,所以这是连接到 presto 的新方法
cursor = presto.connect(presto_host,
presto_port,
requests_kwargs={'auth': HTTPBasicAuth(presto_username, presto_password)},
poll_interval=1,
protocol='https',
source='pyhive').cursor()