Skip to content

Commit d28ca39

Browse files
committed
feat(db): add support for PostgreSQL and SQLite
1 parent df135bf commit d28ca39

6 files changed

Lines changed: 293 additions & 74 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
+ [ ] 提供英文文档版本
6262

63-
+ [ ] 提供 PostgreSQL、SQLite 数据库支持
63+
+ [x] 提供 PostgreSQL、SQLite 数据库支持
6464

6565
+ [x] 提供完整的 run 方法
6666

fastapi_builder/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ class License(BaseEnum):
4141

4242

4343
class Database(BaseEnum):
44-
# POSTGRES = "Postgres"
44+
POSTGRESQL = "PostgreSQL"
4545
MYSQL = "MySQL"
46+
SQLITE = "SQLite"
4647

4748

4849
class DBCmd(BaseEnum):

fastapi_builder/templates/project/{{ cookiecutter.folder_name }}/pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ readme = "README.md"
1212
[tool.poetry.dependencies]
1313
python = "^{{ cookiecutter.python }}"
1414
fastapi = "{{ cookiecutter.fastapi }}"
15+
{% if cookiecutter.database == 'MySQL' -%}
1516
aiomysql = "^0.2.0"
17+
pymysql = "^1.1.1"
18+
{% endif -%}
19+
{% if cookiecutter.database == 'PostgreSQL' -%}
20+
asyncpg = "^0.29.0"
21+
psycopg2-binary = "^2.9.9"
22+
{% endif -%}
23+
{% if cookiecutter.database == 'SQLite' -%}
24+
aiosqlite = "^0.19.0"
25+
{% endif -%}
1626
alembic = "^1.13.2"
1727
bcrypt = "^4.2.0"
1828
databases = "^0.9.0"
1929
email-validator = "^2.2.0"
2030
loguru = "^0.7.2"
2131
passlib = "^1.7.4"
22-
pymysql = "^1.1.1"
2332
python-jose = "^3.3.0"
2433
python-multipart = "^0.0.9"
2534
redis = "^5.0.8"

fastapi_builder/templates/project/{{ cookiecutter.folder_name }}/requirements.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
{% if cookiecutter.database == 'MySQL' -%}
12
aiomysql==0.2.0
3+
pymysql==1.1.1
4+
{% endif -%}
5+
{% if cookiecutter.database == 'PostgreSQL' -%}
6+
asyncpg==0.29.0
7+
psycopg2-binary==2.9.9
8+
{% endif -%}
9+
{% if cookiecutter.database == 'SQLite' -%}
10+
aiosqlite==0.19.0
11+
{% endif -%}
212
alembic==1.13.2
313
bcrypt==4.2.0
414
databases==0.9.0
@@ -7,7 +17,6 @@ fastapi==^{{ cookiecutter.fastapi }}
717
loguru==0.7.2
818
passlib==1.7.4
919
pydantic==2.8.2
10-
pymysql==1.1.1
1120
python-jose==3.3.0
1221
python-multipart==0.0.9
1322
redis==5.0.8

0 commit comments

Comments
 (0)