Skip to main content

tortoise-orm Tools.

Project description

Smart7_ORM

avatar

项目依赖

包名 版本
tortoise-orm ≥ 0.17.7
aerich ≥ 0.5.8

配置数据库

0x01 项目根目录配置settings.py

# mysql setting
database = {
    "db": 'MySQL',
    "host": "localhost",
    "username": "hubert",
    "password": "hubert",
    "db_name": "test_table",
}
# PostgreSQL setting
database = {
    "db": 'PostgreSQL',
    "host": "localhost",
    "username": "hubert",
    "password": "hubert",
    "db_name": "test_table",
}
# sqlite setting
database = {
    "db": 'SQLite',
    "db_name": "test_table.db",
}

0x02 自动获取模型所在包

from smart7_orm.utils import discover_models

model_list = discover_models()

0x03 数据库设置

from smart7_orm.core import make_sql
from smart7_orm.utils import discover_models

TORTOISE_ORM = {
    "connections": {"default": make_sql().get_url()},
    "apps": {
        "models": {
            "models": ["aerich.models", *discover_models()],
            "default_connection": "default",
        },
    },
}

迁移数据库

0x01 初始化迁移配置

aerich init

0x02 初始化数据库

aerich init-db

0x03 更新模型并进行迁移

aerich migrate

0x04 升级到最新版本

aerich upgrade

0x05 降级到指定版本

aerich downgrade

0x06 显示历史

aerich history

0x06 显示要迁移的头

aerich heads

更多请查看 aerich github

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

smart7_orm-1.0.4.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smart7_orm-1.0.4-py3.7.egg (20.1 kB view details)

Uploaded Egg

File details

Details for the file smart7_orm-1.0.4.tar.gz.

File metadata

  • Download URL: smart7_orm-1.0.4.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.2

File hashes

Hashes for smart7_orm-1.0.4.tar.gz
Algorithm Hash digest
SHA256 c86e9599e9ff3fe13330f437aaaf5f749ff18cf2844bf1b14261897397ad965b
MD5 8ab27e29b4a5e8eb84efd4a52cbc6375
BLAKE2b-256 3cee9c9339cbcadc368b8cc091e2f55486c806480891698d3864349d187c28c5

See more details on using hashes here.

File details

Details for the file smart7_orm-1.0.4-py3.7.egg.

File metadata

  • Download URL: smart7_orm-1.0.4-py3.7.egg
  • Upload date:
  • Size: 20.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.2

File hashes

Hashes for smart7_orm-1.0.4-py3.7.egg
Algorithm Hash digest
SHA256 50dbe7ec905a693e59afb9ef4c66aef0bd7ea160710eefc0a7372b0ffc4bfbbf
MD5 c416a56f6aeb204278f7b79868e245f8
BLAKE2b-256 5fced11be3a6bf1a5e14e2205bef2e80e2749f6c31cb467c94b7c9f395a788a2

See more details on using hashes here.

Supported by

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