Skip to main content

xiaoapi sqlalchemy

Project description

xiaoapi-sqlalchemy

xiaoapi的sqlalchemy扩展包

安装

pip install xiaoapi-sqlalchemy

配置数据库连接url

在 application/settings 中 配置数据库连接url

# 数据库配置项
# 连接引擎官方文档:https://docs.sqlalchemy.org/en/20/core/engines.html
# mysql配置说明:mysql+asyncmy://数据库用户名:数据库密码@数据库地址:数据库端口/数据库名称,需安装asyncmy
# sqlite配置说明:sqlite+aiosqlite:///数据库路径,需安装aiosqlite
SQLALCHEMY_DATABASE_URL = f"sqlite+aiosqlite:///{BASE_DIR}/db.sqlite3"

创建表结构

在 application/settings 中 配置需要迁移的models

# 数据库迁移
# 会将MIGRATE_MODELS里所有的model迁移到数据库表结构
MIGRATE_MODELS = [
    "modules.quickstart.models"
]

在命令行中使用以下命令创建表结构:

python manage.py sqlalchemy create-tables

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xiaoapi-sqlalchemy-0.0.5.tar.gz (13.2 kB view hashes)

Uploaded Source

Built Distribution

xiaoapi_sqlalchemy-0.0.5-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page