Python 安全地将参数传递给配置单元查询
是否有方法安全地将参数传递给配置单元查询?我不想格式化查询字符串。使用MySQL数据库+SQLAlchemy,我可以将参数传递给数据库连接,引擎会为我做这件事。我想做一些像下面这样的事情。但是Python 安全地将参数传递给配置单元查询,python,hadoop,sqlalchemy,hive,Python,Hadoop,Sqlalchemy,Hive,是否有方法安全地将参数传递给配置单元查询?我不想格式化查询字符串。使用MySQL数据库+SQLAlchemy,我可以将参数传递给数据库连接,引擎会为我做这件事。我想做一些像下面这样的事情。但是client.execute函数不接受参数。我正在运行hive 0.10.0 from datetime import date from hive_service import ThriftHive from hive_service.ttypes import HiveServerException f
client.execute
函数不接受参数。我正在运行hive 0.10.0
from datetime import date
from hive_service import ThriftHive
from hive_service.ttypes import HiveServerException
from thrift.transport import TSocket, TTransport
from thrift.protocol import TBinaryProtocol
transport = TSocket.TSocket(settings.HIVE_SERVER, settings.HIVE_PORT)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = ThriftHive.Client(protocol)
transport.open()
q = """
select *
from tbl
where dt = %(query_date)s
limit 10
"""
params = {'query_date':date(2016,1,1)}
client.execute(q, params)
results = client.fetchAll()
我认为您的意思是将参数传递给配置单元查询。但这是一个很好的问题,除了技术性。谢谢你,编辑了我的问题。我想你的意思是把参数传递给蜂巢查询。但这是一个很好的问题,除了技术性。谢谢你,编辑了我的问题。