Metadata-Version: 2.4
Name: lancedb-cli
Version: 0.1.0
Summary: A minimal command line application for managing LanceDB databases
Home-page: https://github.com/codref/lancedb-cli
Author: Davide Dal Farra
Author-email: Davide Dal Farra <davide@codref.org>
License: MIT
Project-URL: Homepage, https://github.com/codref/lancedb-cli
Project-URL: Documentation, https://github.com/codref/lancedb-cli#readme
Project-URL: Repository, https://github.com/codref/lancedb-cli.git
Project-URL: Bug Tracker, https://github.com/codref/lancedb-cli/issues
Keywords: lancedb,cli,database,duckdb
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lancedb>=0.1.0
Requires-Dist: duckdb>=0.5.0
Requires-Dist: typer[all]>=0.9.0
Requires-Dist: rich>=13.0.0
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: pygments>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: flake8>=6.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# lancedb-cli

A minimal command line application for managing LanceDB databases. This CLI tool provides an easy interface to query, update, and manage data stored in LanceDB.

## Features

- **Query Tables**: Retrieve data from LanceDB tables with filtering and column selection
- **Interactive Mode**: Interactive SQL shell with command history and completion
- **Direct SQL Execution**: Run complex SQL queries against LanceDB databases
- **Data Management**: Insert, update, delete, and drop records
- **Schema Inspection**: View the schema of tables
- **Multiple Output Formats**: Display results as formatted tables or JSON
- **Auto-completion**: Interactive mode includes SQL keywords and table name completion

## Installation

Install the package using pip:

```bash
pip install lancedb-cli
```

## Usage

### Command Line

List all tables in a database:

```bash
lsql list-tables /path/to/database
```

Query a table:

```bash
lsql query /path/to/database my_table --limit 10
```

View table schema:

```bash
lsql schema /path/to/database my_table
```

Execute SQL query:

```bash
lsql sql /path/to/database "SELECT * FROM my_table WHERE id > 5"
```

Update records:

```bash
lsql update /path/to/database my_table \
  --set-clause "name='John',age=30" \
  --where "id=1"
```

Delete records:

```bash
lsql delete /path/to/database my_table --where "id=1"
```

Empty a table:

```bash
lsql empty /path/to/database my_table
```

Drop a table:

```bash
lsql drop /path/to/database my_table --confirm
```

### Interactive Mode

Start an interactive session:

```bash
lsql interactive /path/to/database
```

Inside the interactive shell, you can:

- Type SQL queries directly
- Use special commands:
  - `.tables` - List all tables
  - `.schema <table>` - Show table schema
  - `.refresh` - Refresh all table views
  - `.update <table> <set> <where>` - Update rows
  - `.delete <table> <where>` - Delete rows
  - `.empty <table>` - Empty a table
  - `.drop <table>` - Drop a table
  - `.exit` - Exit the interactive shell

## Query Options

- `--limit N`: Limit results to N rows (default: 10)
- `--where <condition>`: Filter rows with SQL WHERE clause
- `--select <columns>`: Select specific columns (comma-separated)
- `--output <format>`: Output format: `table` (default) or `json`

## Development

To set up a development environment:

```bash
git clone https://github.com/yourusername/lancedb-cli.git
cd lancedb-cli
pip install -e ".[dev]"
```

Run tests:

```bash
pytest
```

## Requirements

- Python 3.8 or higher
- lancedb
- duckdb
- typer
- rich
- prompt-toolkit
- pygments

## License

Apache 2.0 - see LICENSE file for details

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Issues

If you encounter any issues or have suggestions, please open an issue on GitHub.
