How to Access Hive via Python?

后端 未结 16 857
小蘑菇
小蘑菇 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:36

    Below python program should work to access hive tables from python:

    import commands
    
    cmd = "hive -S -e 'SELECT * FROM db_name.table_name LIMIT 1;' "
    
    status, output = commands.getstatusoutput(cmd)
    
    if status == 0:
       print output
    else:
       print "error"
    

提交回复
热议问题