Lance Namespace urllib3 Client
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
- gotcha The default client host is `http://localhost:8080`. Users *must* configure the `host` parameter in `lance_namespace_urllib3_client.Configuration` to point to their actual Lance Namespace server endpoint, otherwise, all API calls will fail.
- gotcha This client interacts with a Lance Namespace server. It does not provide the server itself. You need a running instance of a Lance Namespace server to use this client effectively.
- gotcha Authentication mechanisms (e.g., API keys, OAuth) are server-dependent. While the client supports common patterns like `api_key['X-Api-Key']`, it might not be enabled or required by default on your server setup. Consult your server's documentation for required authentication.
- deprecated The Lance Namespace specification and its clients are under active development. While explicit breaking changes are usually noted, the API can evolve. Features like `managed_versioning` (introduced in v0.5.0) reflect ongoing enhancements.
Install
-
pip install lance-namespace-urllib3-client
Imports
- Configuration
from lance_namespace_urllib3_client import Configuration
- ApiClient
from lance_namespace_urllib3_client import ApiClient
- ApiException
from lance_namespace_urllib3_client import ApiException
- TableApi
from lance_namespace_urllib3_client.api.table_api import TableApi
- TableCreation
from lance_namespace_urllib3_client.model.table_creation import TableCreation
- Location
from lance_namespace_urllib3_client.model.location import Location
- Name
from lance_namespace_urllib3_client.model.name import Name
Quickstart
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}")