Brad, after long delay I've updated the code in the wiki and included Python 2.6+ certification in Setting Up HiveServer2 -- Python Client Driver <https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonClientDriver> .
I also added the Ruby client driver in Setting Up HiveServer2 -- Ruby Client Driver <https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-RubyClientDriver> and HiveServer2 Clients -- Ruby Client <https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-RubyClient>. But the other two drivers were created before HiveServer2, so I put them (and Ruby) in Hive Client -- Thrift <https://cwiki.apache.org/confluence/display/Hive/HiveClient#HiveClient-Thrift> . Please let me know if anything needs to be changed. Thanks. -- Lefty On Mon, Feb 3, 2014 at 9:52 AM, Brad Ruderman <[email protected]> wrote: > Hi Lefty- > Thanks for the update. Here is the updated code which has a little bit > more description of the methods available: > > > > import pyhs2 > > > with pyhs2.connect(host='localhost', > > port=10000, > > authMechanism="PLAIN", > > user='root', > > password='test', > > database='default') as conn: > > with conn.cursor() as cur: > > #Show databases > > print cur.getDatabases() > > #Execute query > > cur.execute("select * from table") > > #Return column info from query > > print cur.getSchema() > > #Fetch table results > > for i in cur.fetch(): > > print i > > In addition the driver has been certified for use with Python 2.6 and newer. > > > Here are a few other urls we should reference in other languages (Please note > not maintained by me): > > https://github.com/forward3d/rbhive > > https://github.com/forward/node-hive (not sure if it's maintained) > > https://github.com/wdavidw/node-thrift-hive > > Thanks, > > > Brad > > > > On Mon, Feb 3, 2014 at 8:22 AM, Lefty Leverenz <[email protected]> > wrote: > >> Brad, please review the documentation in the wiki (cut-&-paste from your >> email) and let me know what changes are needed: >> >> - Setting Up HiveServer2: Python Client Driver >> >> <https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonClientDriver> >> - HiveServer2 Clients: Python Client >> >> <https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-PythonClient> >> >> >> Thanks for your contribution. >> >> -- Lefty >> >> >> On Tue, Oct 29, 2013 at 12:55 AM, Lefty Leverenz <[email protected] >> > wrote: >> >>> When it's ready, I can add it to the wikidoc for you if you don't have >>> editing access. >>> >>> -- Lefty >>> >>> >>> On Wed, Oct 23, 2013 at 7:24 PM, Brad Ruderman <[email protected]> >>> wrote: >>> >>>> Thanks Stephen- >>>> I will submit it, its definitely still kinda beta mode. >>>> >>>> Looking for feedback and contributors if anyone is interested. >>>> >>>> Thanks! >>>> B >>>> >>>> >>>> On Wed, Oct 23, 2013 at 4:21 PM, Stephen Sprague <[email protected]> >>>> wrote: >>>> >>>>> excellent. you might try to get it mentioned on this page: >>>>> >>>>> https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients >>>>> >>>>> and save some other poor saps from re-inventing the wheel. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Oct 23, 2013 at 2:42 PM, Brad Ruderman < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi All- >>>>>> I have struggled for awhile with a simple and straightforward driver >>>>>> that I can use to connect to Hive Server 2 in a very similar manner as a >>>>>> mysql driver in python. I know there are a few ways like using thrift or >>>>>> ODBC but all require significant amount of installation. I decided to >>>>>> create my own package that includes all the required packages such as >>>>>> SASL >>>>>> and Thrift wrappers to connect. It is called pyhs2 and is avaliable here: >>>>>> >>>>>> https://github.com/BradRuderman/pyhs2 >>>>>> >>>>>> To use simply: >>>>>> >>>>>> pip install pyhs2 >>>>>> >>>>>> then: >>>>>> >>>>>> import pyhs2 >>>>>> >>>>>> conn = pyhs2.connect(host='localhost', >>>>>> port=10000, >>>>>> authMechanism="PLAIN", >>>>>> user='root', >>>>>> password='test', >>>>>> database='default') >>>>>> cur = conn.cursor() >>>>>> cur.execute("show tables") >>>>>> for i in cur.fetch(): >>>>>> print i >>>>>> cur.close() >>>>>> conn.close() >>>>>> >>>>>> Feel free to use it, I plan to add additional functionality and fix any >>>>>> bugs that exist. Most of the code was repurposed from a variety of >>>>>> sources. I hope you find it useful, please let me know if you have any >>>>>> questions. >>>>>> >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Brad >>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >> >
