Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 安全地将参数传递给配置单元查询_Python_Hadoop_Sqlalchemy_Hive - Fatal编程技术网

Python 安全地将参数传递给配置单元查询

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

是否有方法安全地将参数传递给配置单元查询?我不想格式化查询字符串。使用MySQL数据库+SQLAlchemy,我可以将参数传递给数据库连接,引擎会为我做这件事。我想做一些像下面这样的事情。但是
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()

我认为您的意思是将参数传递给配置单元查询。但这是一个很好的问题,除了技术性。谢谢你,编辑了我的问题。我想你的意思是把参数传递给蜂巢查询。但这是一个很好的问题,除了技术性。谢谢你,编辑了我的问题。