Skip to main content

一个通用数据库连接插件

Project description

通用 ORM 数据库连接插件

施工中。。。

  • 参考 example_bot 来创建一个 聊天记录 插件吧~!

.env 设置

参考配置:

# db_url=postgres://postgres@localhost:5432/postgres
db_url=sqlite://db.sqlite3
db_generate_schemas=false

db_url

使用 sqlite

直接使用相对路径来建立

db_url=sqlite://db.sqlite3

如果时指定路径,则应该是

db_url=sqlite:///data/db.sqlite

使用绝对路径 注意有三个 /

使用 PostgreSQL

db_url=postgres://postgres:pass@db.host:5432/somedb
  • 说明: postgres:// 表示协议
  • postgres:pass@ 表示登入账号和密码 如果没有密码则用 postgres@
  • db.host:5432 表示数据库的地址 和 端口 如果是本机 则为 localhost:5432
  • /somedb 表示数据库名

使用 MySQL/MariaDB

db_url=mysql://myuser:mypass:pass@db.host:3306/somedb

跟上面的差不多

db_generate_schemas

  • 填入 truefalse
  • 默认 false
  • 如为 true 则会在每次启动时,在空的数据库上初始化数据表
    • 请在第一次启动有新数据表时设置为 true 来初始化表,随后设置为false 关闭该功能

数据库类型

  • postgres
  • sqlite
  • MySQL/MariaDB

其他待补充

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

nonebot-plugin-tortoise-orm-0.0.1a1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

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