Metadata-Version: 2.1
Name: tortoise-cli
Version: 0.1.0
Summary: A cli tool for tortoise-orm, build on top of click and ptpython.
Home-page: https://github.com/tortoise/tortoise-cli
License: Apache-2.0
Keywords: tortoise,shell,cli,tortoise-orm
Author: long2ice
Author-email: long2ice@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: click
Requires-Dist: ptpython
Requires-Dist: tortoise-orm
Project-URL: Documentation, https://github.com/tortoise/tortoise-cli
Project-URL: Repository, https://github.com/tortoise/tortoise-cli.git
Description-Content-Type: text/markdown

# tortoise-cli

[![image](https://img.shields.io/pypi/v/tortoise-cli.svg?style=flat)](https://pypi.python.org/pypi/tortoise-cli)
[![image](https://img.shields.io/github/license/tortoise/tortoise-cli)](https://github.com/tortoise/tortoise-cli)
[![image](https://github.com/tortoise/tortoise-cli/workflows/pypi/badge.svg)](https://github.com/tortoise/tortoise-cli/actions?query=workflow:pypi)

A cli tool for tortoise-orm, build on top of click and ptpython.

## Installation

You can just install from pypi.

```shell
pip install tortoise-cli
```

## Quick Start

```shell
> tortoise-cli -h                                                                                                                                                                 23:59:38
Usage: tortoise-cli [OPTIONS] COMMAND [ARGS]...

Options:
  -V, --version      Show the version and exit.
  -c, --config TEXT  TortoiseORM config dictionary path, like
                     settings.TORTOISE_ORM  [required]
  -h, --help         Show this message and exit.

Commands:
  shell  Start an interactive shell.
```

## Usage

First, you need make a TortoiseORM config object, assuming that in `settings.py`.

```python
TORTOISE_ORM = {
    "connections": {
        "default": 'sqlite://:memory:',
    },
    "apps": {
        "models": {"models": ["examples.models"], "default_connection": "default"},
    },
}
```

## Interactive shell

Then you can start an interactive shell for TortoiseORM.

```shell
tortoise-cli -c settings.TORTOISE_ORM shell
```

Or you can set config by set environment variable.

```shell
export TORTOISE_ORM=settings.TORTOISE_ORM
```

Then just run:

```shell
tortoise-cli shell
```

## License

This project is licensed under the
[Apache-2.0](https://github.com/tortoise/tortoise-cli/blob/main/LICENSE) License.

