Skip to main content

50 posts tagged with "轻量级后端"

View All Tags

FastAPI 连接 MySQL

· 6 min read
Kimi Gao
Fullstack & AI

安装数据库驱动

Python 安装包中没有集成 MySQL 数据库驱动,而 ORM 框架 SQLAlchemy 依赖于数据库驱动,所以第一步需要安装 MySQL 驱动。在 Python 3.x 中推荐使用 PyMySQL,其遵循 Python 数据库 API v2.0 规范,并完全使用 Python 代码实现。

pip install pymysql

示例目录结构如下:

.
├── sql_app
│ ├── __init__.py
│ ├── database.py
│ ├── models.py
│ ├── schemas.py
│ ├── crud.py
│ ├── routers.py
│ └── sql_app.db
└── main.py

yarn 使用

· 16 min read
Kimi Gao
Fullstack & AI

Get started

macOS

  1. 使用脚本安装,每次安装的都是最新版:
curl -o- -L https://yarnpkg.com/install.sh | bash

如需升级,再次运行此命令,然后会出现以下信息:

/Users/xxx/.yarn already exists, possibly from a past Yarn install.
> Remove it (rm -rf /Users/xxx/.yarn) and run this script again.

根据提示,由于已经安装了 yarn,所以需要先删除~/.yarn文件,然后再重新执行该命令,即可安装最新版 yarn。