pymetastore
is a Python client for Hive Metastore.
- Python-friendly interface for Hive Metastore
- Comprehensive support for metadata operations
- Fully compatible with the Hive metastore service over Thrift protocol
Install pymetastore with pip:
pip install pymetastore
Here's a taste of using pymetastore
to connect to Hive Metastore and interact with metadata:
from pymetastore.metastore import HMS
with HMS.create(host="localhost", port=9083) as hms:
databases = hms.list_databases()
database = hms.get_database(name="test_db")
tables = hms.list_tables(database_name=database.name)
table = hms.get_table(
database_name=database.name,
table_name=tables[0],
)
partitions = hms.list_partitions(
database_name=database.name,
table_name=table.name,
)
partition = hms.get_partition(
database_name=database.name,
table_name=table.name,
partition_name="partition=1",
)