Skip to content

Commit 1c5bd0e

Browse files
committed
init
1 parent 7caabc0 commit 1c5bd0e

File tree

16 files changed

+1021
-1
lines changed

16 files changed

+1021
-1
lines changed

.github/workflows/pypi.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: pypi
2+
on:
3+
release:
4+
types:
5+
- created
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-python@v2
12+
with:
13+
python-version: '3.x'
14+
- name: Install and configure Poetry
15+
uses: snok/[email protected]
16+
with:
17+
virtualenvs-create: false
18+
- name: Build dists
19+
run: make build
20+
- name: Pypi Publish
21+
uses: pypa/gh-action-pypi-publish@master
22+
with:
23+
user: __token__
24+
password: ${{ secrets.pypi_password }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
.idea

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Whitespace-only changes.

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
checkfiles = tortoise_cli/ tests/ examples/ conftest.py
2+
black_opts = -l 100 -t py38
3+
py_warn = PYTHONDEVMODE=1
4+
5+
up:
6+
@poetry update
7+
8+
deps:
9+
@poetry install
10+
11+
style: deps
12+
isort -src $(checkfiles)
13+
black $(black_opts) $(checkfiles)
14+
15+
check: deps
16+
black --check $(black_opts) $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
17+
flake8 $(checkfiles)
18+
mypy $(checkfiles)
19+
20+
21+
test: deps
22+
$(py_warn) py.test
23+
24+
build: deps
25+
@poetry build
26+
27+
ci: check test

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,59 @@
11
# tortoise-cli
2-
A manage shell for tortoise-orm, build on top of ptpython
2+
3+
[![image](https://img.shields.io/pypi/v/tortoise-cli.svg?style=flat)](https://pypi.python.org/pypi/tortoise-cli)
4+
[![image](https://img.shields.io/github/license/tortoise/tortoise-cli)](https://github.com/tortoise/tortoise-cli)
5+
[![image](https://github.com/tortoise/tortoise-cli/workflows/pypi/badge.svg)](https://github.com/tortoise/tortoise-cli/actions?query=workflow:pypi)
6+
7+
A cli tool for tortoise-orm, build on top of click and ptpython.
8+
9+
## Installation
10+
11+
You can just install from pypi.
12+
13+
```shell
14+
pip install tortoise-cli
15+
```
16+
17+
## Quick Start
18+
19+
```shell
20+
> tortoise-cli -h 23:59:38
21+
Usage: tortoise-cli [OPTIONS] COMMAND [ARGS]...
22+
23+
Options:
24+
-V, --version Show the version and exit.
25+
-c, --config TEXT TortoiseORM config dictionary path, like
26+
settings.TORTOISE_ORM [required]
27+
-h, --help Show this message and exit.
28+
29+
Commands:
30+
shell Start an interactive shell.
31+
```
32+
33+
## Usage
34+
35+
First, you need make a TortoiseORM config object, assuming that in `settings.py`.
36+
37+
```python
38+
TORTOISE_ORM = {
39+
"connections": {
40+
"default": 'sqlite://:memory:',
41+
},
42+
"apps": {
43+
"models": {"models": ["examples.models"], "default_connection": "default"},
44+
},
45+
}
46+
```
47+
48+
## Interactive shell
49+
50+
Then you can start an interactive shell for TortoiseORM.
51+
52+
```shell
53+
tortoise-cli -c examples.TORTOISE_ORM shell
54+
```
55+
56+
## License
57+
58+
This project is licensed under the
59+
[Apache-2.0](https://github.com/tortoise/tortoise-cli/blob/main/LICENSE) License.

conftest.py

Whitespace-only changes.

examples/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TORTOISE_ORM = {
2+
"connections": {
3+
"default": "sqlite://:memory:",
4+
},
5+
"apps": {
6+
"models": {"models": ["examples.models"], "default_connection": "default"},
7+
},
8+
}

examples/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from tortoise import Model, fields
2+
3+
4+
class User(Model):
5+
name = fields.CharField(max_length=20)
6+
age = fields.IntField()

0 commit comments

Comments
 (0)