Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.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_Hive_Hiveql - Fatal编程技术网

运行配置单元查询的Python脚本

运行配置单元查询的Python脚本,python,hive,hiveql,Python,Hive,Hiveql,有谁能指导我如何使用Python运行.hql查询吗。尝试了Hiveutils库,但它不在开发环境中。还有其他执行查询的方法吗?您可以使用:PyHive是用于Presto和Hive的Python DB-API和SQLAlchemy接口的集合 例如: from pyhive import hive cursor = hive.connect('localhost').cursor() cursor.execute('SELECT * FROM my_awesome_data LIMIT 10') p

有谁能指导我如何使用Python运行.hql查询吗。尝试了Hiveutils库,但它不在开发环境中。还有其他执行查询的方法吗?

您可以使用:PyHive是用于Presto和Hive的Python DB-API和SQLAlchemy接口的集合

例如:

from pyhive import hive
cursor = hive.connect('localhost').cursor()
cursor.execute('SELECT * FROM my_awesome_data LIMIT 10')
print(cursor.fetchone())
print(cursor.fetchall())
您可以使用:PyHive是用于Presto和Hive的Python DB-API和SQLAlchemy接口的集合

例如:

from pyhive import hive
cursor = hive.connect('localhost').cursor()
cursor.execute('SELECT * FROM my_awesome_data LIMIT 10')
print(cursor.fetchone())
print(cursor.fetchall())

您可以尝试使用pyhs2,尝试像下面给出的示例那样工作

    import pyhs2
    with pyhs2.connect(host='localhost',
           port=10000,
           authMechanism="PLAIN",
           user='your_user',
           password='your_password',
           database='your_default_db') as conn:
        with conn.cursor() as cur:
            print cur.getDatabases()
            cur.execute("select * from table")
            #Return info from query
            print cur.getSchema()

您可以尝试使用pyhs2,尝试像下面给出的示例那样工作

    import pyhs2
    with pyhs2.connect(host='localhost',
           port=10000,
           authMechanism="PLAIN",
           user='your_user',
           password='your_password',
           database='your_default_db') as conn:
        with conn.cursor() as cur:
            print cur.getDatabases()
            cur.execute("select * from table")
            #Return info from query
            print cur.getSchema()

上次我检查时,PyHive的“稳定”版本被破坏了,即使是在蟒蛇回购中。你必须重新编译“最新”的SASL库来修复这个问题。上次我检查时,PyHive的“稳定”版本被破坏了,即使是在Anaconda repos中。你必须重新编译“最新”的SASL库来解决这个问题。还有ImPyla,它支持Hive和Impala(使用相同的二进制协议)。上次我检查时,它起作用了。PyHive的情况并非如此,还有支持Hive和Impala(使用相同的二进制协议)的ImPyla。上次我检查时,它起作用了。PyHive的情况并非如此。