How to Access Hive via Python?

后端 未结 16 880
小蘑菇
小蘑菇 2020-11-30 17:11

https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-Python appears to be outdated.

When I add this to /etc/profile:

export PYTHONP         


        
16条回答
  •  悲哀的现实
    2020-11-30 17:38

    To connect using a username/password and specifying ports, the code looks like this:

    from pyhive import presto
    
    cursor = presto.connect(host='host.example.com',
                        port=8081,
                        username='USERNAME:PASSWORD').cursor()
    
    sql = 'select * from table limit 10'
    
    cursor.execute(sql)
    
    print(cursor.fetchone())
    print(cursor.fetchall())
    

提交回复
热议问题