Demo entry 6683911

Py

   

Submitted by anonymous on Dec 14, 2017 at 03:02
Language: Python. Code size: 676 Bytes.

def test_hive():
    import pyhs2
    with pyhs2.connect(host='localhost',
                       port=10000,
                       authMechanism="PLAIN",
                       user='lihuaping',
                       password='lihuaping',
                       database='company') as conn:
        with conn.cursor() as cur:

            # Show databases
            print cur.getDatabases()

            # Execute query
            cur.execute("select * from wangzhan limit 10")

            # Return column info from query
            print cur.getSchema()

            # Fetch table results
            for i in cur.fetch():
                print i

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).