Skip to content

Commit 86186fb

Browse files
committed
tortoise 제거
1 parent 4ef49af commit 86186fb

File tree

23 files changed

+38
-284
lines changed

23 files changed

+38
-284
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ docker run --rm -it -v "$(pwd):/projects" s3rius/fastapi_template
4545
One of the coolest features is that this project is extremely configurable.
4646
You can choose between different databases and even ORMs, or
4747
you can even generate a project without a database!
48-
Currently SQLAlchemy 2.0, TortoiseORM, and Piccolo are supported.
48+
Currently SQLAlchemy 2.0, and Piccolo are supported.
4949

5050
This project can run as TUI or CLI and has excellent code documentation.
5151

@@ -85,7 +85,7 @@ Options:
8585
--quite Do not ask for features during generation
8686
--api-type [rest] Select API type for your application
8787
--db [none|mysql|postgresql] Select a database for your app
88-
--orm [none|sqlalchemy|tortoise|psycopg|piccolo]
88+
--orm [none|sqlalchemy|psycopg|piccolo]
8989
Choose Object–Relational Mapper lib
9090
--ci [none|gitlab_ci] Select a CI for your app
9191
--redis Add redis support

fastapi_template/cli.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,6 @@ def checker(ctx: BuilderContext) -> bool:
221221
)
222222
),
223223
),
224-
MenuEntry(
225-
code="tortoise",
226-
user_view="Tortoise",
227-
description=(
228-
"{what} is a great {feature} ORM.\n"
229-
"It's easy to use, it has it's own migration tooling.".format(
230-
what=colored("Tortoise", color="green"),
231-
feature=colored("fully-async", color="cyan"),
232-
)
233-
),
234-
is_hidden=always_hidden(),
235-
),
236224
MenuEntry(
237225
code="psycopg",
238226
user_view="PsycoPG",

fastapi_template/template/{{cookiecutter.project_name}}/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ alembic upgrade "<revision_id>"
161161
162162
# To perform all pending migrations.
163163
alembic upgrade "head"
164-
{%- elif cookiecutter.orm == 'tortoise' %}
165-
# Upgrade database to the last migration.
166-
aerich upgrade
167164
168165
{%- elif cookiecutter.orm == 'piccolo' %}
169166
# You have to set a PICCOLO_CONF variable
@@ -183,8 +180,6 @@ alembic downgrade <revision_id>
183180
184181
# Revert everything.
185182
alembic downgrade base
186-
{%- elif cookiecutter.orm == 'tortoise' %}
187-
aerich downgrade
188183
{%- endif %}
189184
```
190185
@@ -198,8 +193,6 @@ alembic revision --autogenerate
198193
199194
# For empty file generation.
200195
alembic revision
201-
{%- elif cookiecutter.orm == 'tortoise' %}
202-
aerich migrate
203196
{%- endif %}
204197
```
205198
{%- endif %}

fastapi_template/template/{{cookiecutter.project_name}}/conditional_files.json

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"resources": [
6363
"alembic.ini",
6464
"{{cookiecutter.project_name}}/db_sa/migrations",
65-
"{{cookiecutter.project_name}}/db_tortoise/migrations",
6665
"{{cookiecutter.project_name}}/db_piccolo/migrations"
6766
]
6867
},
@@ -111,16 +110,12 @@
111110
"{{cookiecutter.project_name}}/web/api/dummy",
112111
"{{cookiecutter.project_name}}/db_sa/dao",
113112
"{{cookiecutter.project_name}}/db_sa/models/dummy_model.py",
114-
"{{cookiecutter.project_name}}/db_tortoise/dao",
115-
"{{cookiecutter.project_name}}/db_tortoise/models/dummy_model.py",
116113
"{{cookiecutter.project_name}}/db_psycopg/dao",
117114
"{{cookiecutter.project_name}}/db_psycopg/models/dummy_model.py",
118115
"{{cookiecutter.project_name}}/tests/test_dummy.py",
119116
"{{cookiecutter.project_name}}/db_piccolo/dao",
120117
"{{cookiecutter.project_name}}/db_piccolo/models/dummy_model.py",
121118
"{{cookiecutter.project_name}}/db_sa/migrations/versions/2021-08-16-16-55_2b7380507a71.py",
122-
"{{cookiecutter.project_name}}/db_tortoise/migrations/models/1_20210928165300_init_dummy_pg.sql",
123-
"{{cookiecutter.project_name}}/db_tortoise/migrations/models/1_20210928165300_init_dummy_mysql.sql",
124119
"{{cookiecutter.project_name}}/db_piccolo/migrations/2022-04-16T17-38-51-672827.py"
125120
]
126121
},
@@ -137,12 +132,6 @@
137132
"{{cookiecutter.project_name}}/db_sa"
138133
]
139134
},
140-
"Tortoise ORM": {
141-
"enabled": "{{cookiecutter.orm == 'tortoise'}}",
142-
"resources": [
143-
"{{cookiecutter.project_name}}/db_tortoise"
144-
]
145-
},
146135
"PsycoPG": {
147136
"enabled": "{{cookiecutter.orm == 'psycopg'}}",
148137
"resources": [
@@ -156,20 +145,6 @@
156145
"{{cookiecutter.project_name}}/piccolo_conf.py"
157146
]
158147
},
159-
"Postgresql DB": {
160-
"enabled": "{{cookiecutter.db_info.name == 'postgresql'}}",
161-
"resources": [
162-
"{{cookiecutter.project_name}}/db_tortoise/migrations/models/0_20210928165300_init_pg.sql",
163-
"{{cookiecutter.project_name}}/db_tortoise/migrations/models/1_20210928165300_init_dummy_pg.sql"
164-
]
165-
},
166-
"MySQL DB": {
167-
"enabled": "{{cookiecutter.db_info.name == 'mysql'}}",
168-
"resources": [
169-
"{{cookiecutter.project_name}}/db_tortoise/migrations/models/0_20210928165300_init_mysql.sql",
170-
"{{cookiecutter.project_name}}/db_tortoise/migrations/models/1_20210928165300_init_dummy_mysql.sql"
171-
]
172-
},
173148
"Opentelemetry support": {
174149
"enabled": "{{cookiecutter.otlp_enabled}}",
175150
"resources": [

fastapi_template/template/{{cookiecutter.project_name}}/deploy/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ services:
120120
restart: "no"
121121
{%- if cookiecutter.orm in ['sqlalchemy'] %}
122122
command: alembic upgrade head
123-
{%- elif cookiecutter.orm == 'tortoise' %}
124-
command: aerich upgrade
125123
{%- elif cookiecutter.orm == 'piccolo' %}
126124
command: piccolo migrations forwards all
127125
{%- endif %}

fastapi_template/template/{{cookiecutter.project_name}}/deploy/kube/db.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ spec:
7171
- "alembic"
7272
- "upgrade"
7373
- "head"
74-
{%- elif cookiecutter.orm == 'tortoise' %}
75-
- "aerich"
76-
- "upgrade"
7774
{%- elif cookiecutter.orm == 'piccolo' %}
7875
- "piccolo"
7976
- "migrations"

fastapi_template/template/{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,36 @@ uvicorn = { version = "^0.25.0", extras = ["standard"] }
1818
gunicorn = "^21.2.0"
1919
{%- endif %}
2020
{%- if cookiecutter.add_users == "True" %}
21-
{%- if cookiecutter.orm == "sqlalchemy" %}
21+
{%- if cookiecutter.orm == "sqlalchemy" %}
2222
fastapi-users = "^12.1.2"
2323
httpx-oauth = "^0.13.1"
2424
fastapi-users-db-sqlmodel = "^0.3.0"
25-
{%- endif %}
25+
{%- endif %}
2626
{%- endif %}
2727
{%- if cookiecutter.pydanticv1 == "True" %}
2828
pydantic = { version = "^1", extras=["dotenv"] }
29-
{%- else %}
29+
{%- else %}
3030
pydantic = "^2"
3131
pydantic-settings = "^2"
3232
{%- endif %}
3333
yarl = "^1.9.2"
3434
ujson = "^5.8.0"
3535
{%- if cookiecutter.orm == "piccolo" %}
36-
{%- if cookiecutter.db_info.name == "postgresql" %}
36+
{%- if cookiecutter.db_info.name == "postgresql" %}
3737
piccolo = {version = "^0.117.0", extras = ["postgres"]}
38-
{%- endif %}
38+
{%- endif %}
3939
{%- endif %}
4040
{%- if cookiecutter.orm == "sqlalchemy" %}
4141
SQLAlchemy = {version = "^2.0.18", extras = ["asyncio"]}
42-
{%- if cookiecutter.enable_migrations == "True" %}
42+
{%- if cookiecutter.enable_migrations == "True" %}
4343
alembic = "^1.11.1"
44-
{%- endif %}
45-
{%- if cookiecutter.db_info.name == "postgresql" %}
44+
{%- endif %}
45+
{%- if cookiecutter.db_info.name == "postgresql" %}
4646
asyncpg = {version = "^0.29.0", extras = ["sa"]}
47-
{%- elif cookiecutter.db_info.name == "mysql" %}
47+
{%- elif cookiecutter.db_info.name == "mysql" %}
4848
aiomysql = "^0.2.0"
4949
mysqlclient = "^2.2.1"
50-
{%- endif %}
51-
{%- endif %}
52-
{%- if cookiecutter.orm == "tortoise" %}
53-
tortoise-orm = "^0.19.3"
54-
{%- if cookiecutter.enable_migrations == "True" %}
55-
aerich = "^0.7.1"
56-
{%- endif %}
57-
{%- if cookiecutter.db_info.name == "postgresql" %}
58-
asyncpg = "^0.29.0"
59-
{%- elif cookiecutter.db_info.name == "mysql" %}
60-
aiomysql = "^0.2.0"
61-
mysqlclient = "^2.2.0"
62-
cryptography = "^41.0.1"
63-
{%- endif %}
50+
{%- endif %}
6451
{%- endif %}
6552
{%- if cookiecutter.enable_redis == "True" %}
6653
redis = {version = "^5.0.1", extras = ["hiredis"]}
@@ -88,21 +75,21 @@ opentelemetry-sdk = "^1.22.0"
8875
opentelemetry-exporter-otlp = "^1.22.0"
8976
opentelemetry-instrumentation = "^0.43b0"
9077
opentelemetry-instrumentation-fastapi = "^0.43b0"
91-
{%- if cookiecutter.enable_loguru != "True" %}
78+
{%- if cookiecutter.enable_loguru != "True" %}
9279
opentelemetry-instrumentation-logging = "^0.43b0"
93-
{%- endif %}
94-
{%- if cookiecutter.enable_redis == "True" %}
80+
{%- endif %}
81+
{%- if cookiecutter.enable_redis == "True" %}
9582
opentelemetry-instrumentation-redis = "^0.43b0"
96-
{%- endif %}
97-
{%- if cookiecutter.db_info.name == "postgresql" %}
83+
{%- endif %}
84+
{%- if cookiecutter.db_info.name == "postgresql" %}
9885
opentelemetry-instrumentation-asyncpg = "^0.43b0"
99-
{%- endif %}
100-
{%- if cookiecutter.orm == "sqlalchemy" %}
86+
{%- endif %}
87+
{%- if cookiecutter.orm == "sqlalchemy" %}
10188
opentelemetry-instrumentation-sqlalchemy = "^0.43b0"
102-
{%- endif %}
103-
{%- if cookiecutter.enable_rmq == "True" %}
89+
{%- endif %}
90+
{%- if cookiecutter.enable_rmq == "True" %}
10491
opentelemetry-instrumentation-aio-pika = "^0.43b0"
105-
{%- endif %}
92+
{%- endif %}
10693
{%- endif %}
10794
{%- if cookiecutter.enable_loguru == "True" %}
10895
loguru = "^0.7.0"
@@ -114,19 +101,15 @@ aiokafka = "^0.10.0"
114101
{%- if cookiecutter.enable_taskiq == "True" %}
115102
taskiq = "^0"
116103
taskiq-fastapi = "^0"
117-
118104
{%- if cookiecutter.enable_redis == "True" %}
119105
taskiq-redis = "^0"
120106
{%- endif %}
121-
122107
{%- if cookiecutter.enable_rmq == "True" %}
123108
taskiq-aio-pika = "^0"
124109
{%- endif %}
125-
126110
{%- if (cookiecutter.enable_rmq or cookiecutter.enable_rmq) != "True" %}
127111
pyzmq = "^25"
128112
{%- endif %}
129-
130113
{%- endif %}
131114
stackprinter = "^0.2.11"
132115

@@ -146,10 +129,6 @@ pytest-env = "^1.1.3"
146129
{%- if cookiecutter.enable_redis == "True" %}
147130
fakeredis = "^2.5.0"
148131
{%- endif %}
149-
{%- if cookiecutter.orm == "tortoise" %}
150-
asynctest = "^0.13.0"
151-
nest-asyncio = "^1.5.6"
152-
{%- endif %}
153132
httpx = "^0.25.2"
154133
{%- if cookiecutter.enable_taskiq == "True" %}
155134
taskiq = { version = "^0", extras = ["reload"] }
@@ -218,20 +197,12 @@ extend-exclude = '''
218197
)
219198
'''
220199

221-
{%- if cookiecutter.orm == "tortoise" %}
222-
{%- if cookiecutter.enable_migrations == "True" %}
223-
[tool.aerich]
224-
tortoise_orm = "{{cookiecutter.project_name}}.db.config.TORTOISE_CONFIG"
225-
location = "./{{cookiecutter.project_name}}/db/migrations"
226-
src_folder = "./{{cookiecutter.project_name}}"
227-
{%- endif %}
228-
{%- endif %}
229200

230201
[fastapi-template.options]
231202
{%- for key, value in cookiecutter.items() %}
232-
{%- if not key.startswith("_") and not key == "db_info" %}
203+
{%- if not key.startswith("_") and not key == "db_info" %}
233204
{{key}} = "{{value}}"
234-
{%- endif %}
205+
{%- endif %}
235206
{%- endfor %}
236207

237208
[build-system]

fastapi_template/template/{{cookiecutter.project_name}}/replaceable_files.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"{{cookiecutter.project_name}}/db": [
33
"{{cookiecutter.project_name}}/db_sa",
4-
"{{cookiecutter.project_name}}/db_tortoise",
54
"{{cookiecutter.project_name}}/db_psycopg",
65
"{{cookiecutter.project_name}}/db_piccolo"
76
]

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/conftest.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@
4343
from {{cookiecutter.project_name}}.db.dependencies import get_db_session
4444
from {{cookiecutter.project_name}}.db.utils import create_database, drop_database
4545

46-
{%- elif cookiecutter.orm == "tortoise" %}
47-
import nest_asyncio
48-
from tortoise import Tortoise
49-
from tortoise.contrib.test import finalizer, initializer
50-
from {{cookiecutter.project_name}}.db.config import MODELS_MODULES, TORTOISE_CONFIG
51-
52-
nest_asyncio.apply()
53-
5446
{%- elif cookiecutter.orm == "psycopg" %}
5547
from psycopg import AsyncConnection
5648
from psycopg_pool import AsyncConnectionPool
@@ -130,27 +122,6 @@ async def dbsession(
130122
await trans.rollback()
131123
await connection.close()
132124

133-
{%- elif cookiecutter.orm == "tortoise" %}
134-
135-
@pytest.fixture(autouse=True)
136-
async def initialize_db() -> AsyncGenerator[None, None]:
137-
"""
138-
Initialize models and database.
139-
140-
:yields: Nothing.
141-
"""
142-
initializer(
143-
MODELS_MODULES,
144-
db_url=str(settings.db_url),
145-
app_label="models",
146-
)
147-
await Tortoise.init(config=TORTOISE_CONFIG)
148-
149-
yield
150-
151-
await Tortoise.close_connections()
152-
finalizer()
153-
154125
{%- elif cookiecutter.orm == "psycopg" %}
155126

156127
async def drop_db() -> None:

fastapi_template/template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/db_tortoise/config.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)