{"library":"pyhs2","title":"Python Hive Server 2 Client Driver","description":"pyHS2 is a Python client driver designed for connecting to Hive Server 2. The project's last stable release was 0.6.0 in November 2014. It is no longer actively maintained, with the developer ceasing support in early 2016 and recommending alternative libraries.","language":"python","status":"abandoned","last_verified":"Thu Apr 16","install":{"commands":["pip install pyhs2"],"cli":null},"imports":["import pyhs2\nconn = pyhs2.connect(...)","from pyhs2.error import Pyhs2Exception"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport pyhs2\n\nhive_host = os.environ.get('HIVE_HOST', 'localhost')\nhive_port = int(os.environ.get('HIVE_PORT', '10000'))\nhive_user = os.environ.get('HIVE_USER', 'hive')\nhive_password = os.environ.get('HIVE_PASSWORD', '')\nhive_database = os.environ.get('HIVE_DATABASE', 'default')\n\ntry:\n    with pyhs2.connect(\n        host=hive_host,\n        port=hive_port,\n        authMechanism=\"PLAIN\", # or \"KERBEROS\" or None\n        user=hive_user,\n        password=hive_password,\n        database=hive_database\n    ) as conn:\n        print(\"Successfully connected to Hive Server 2.\")\n        with conn.cursor() as cur:\n            # Show databases\n            print(f\"Databases: {cur.getDatabases()}\")\n\n            # Execute a query\n            cur.execute(\"SELECT * FROM some_table LIMIT 5\")\n\n            # Return column info\n            print(f\"Schema: {cur.getSchema()}\")\n\n            # Fetch table results\n            print(\"Query Results:\")\n            for row in cur.fetch():\n                print(row)\n\nexcept pyhs2.error.Pyhs2Exception as e:\n    print(f\"pyhs2 error: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to establish a connection to Hive Server 2 using `pyhs2`, execute a sample query, retrieve schema information, and fetch results. It uses environment variables for connection parameters for flexibility. Ensure your Hive Server 2 is running and accessible.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}