Lance Namespace urllib3 Client

0.6.1 · active · verified Thu Apr 09

The `lance-namespace-urllib3-client` is an auto-generated Python client library for interacting with a Lance Namespace server, adhering to the Lance Namespace Specification. It provides methods for managing tables, including creation, declaration, and versioning operations. The current version is 0.6.1, and the library follows a rapid release cadence with frequent minor updates and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the client, configure its host, and declare a new table with `declare_table`. It also includes an example of retrieving the declared table using `get_table`. Remember to set the `LANCE_NAMESPACE_HOST` environment variable or modify the configuration directly to point to your Lance Namespace server.

import os
from pprint import pprint

from lance_namespace_urllib3_client import Configuration, ApiClient, ApiException
from lance_namespace_urllib3_client.api.table_api import TableApi
from lance_namespace_urllib3_client.model.table_creation import TableCreation
from lance_namespace_urllib3_client.model.location import Location
from lance_namespace_urllib3_client.model.name import Name

# Configure API client. Replace with your Lance Namespace server host.
# You can also pass API keys for authentication if required by your server.
configuration = Configuration(
    host = os.environ.get('LANCE_NAMESPACE_HOST', 'http://localhost:8080')
)
# if os.environ.get('LANCE_API_KEY'):
#     configuration.api_key['X-Api-Key'] = os.environ.get('LANCE_API_KEY')

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the TableApi class
    api_instance = TableApi(api_client)

    # Define table details
    table_name = Name('my_first_table')
    table_creation_body = TableCreation(
        location = Location(
            uri="s3://my-test-bucket/data/my_first_table", # Required: URI where table data is stored
        ),
        managed_versioning=True, # Enable or disable managed versioning for the table
        properties={
            "owner": "data_team",
            "environment": "dev"
        }
    )

    try:
        # Call the declare_table API to register a new table
        api_response = api_instance.declare_table(table_name, table_creation_body)
        print("Successfully declared table:")
        pprint(api_response)
    except ApiException as e:
        print(f"Exception when calling TableApi->declare_table: {e}")

# Example of retrieving a table
with ApiClient(configuration) as api_client:
    api_instance = TableApi(api_client)
    try:
        get_table_response = api_instance.get_table(table_name)
        print("\nSuccessfully retrieved table:")
        pprint(get_table_response)
    except ApiException as e:
        print(f"Exception when calling TableApi->get_table: {e}")

view raw JSON →