gpt4 book ai didi

django - 让django在 "migrate"上自动创建数据库

转载 作者:行者123 更新时间:2023-12-02 05:20:40 26 4
gpt4 key购买 nike

在开发环境中,有一种方法可以让 django 在“迁移”命令上自动创建数据库(在 postgreSQL 服务器上),就像创建测试数据库时一样?

我的最终目标是为每个 git 分支建立一个数据库。

最佳答案

是的,Django 在“迁移”上创建了一个数据库。但前提是它使用 SQLite。
文档清楚地说明了这一点
( https://docs.djangoproject.com/en/3.1/intro/tutorial02/ )

For databases other than SQLite

If you’re using a database besides SQLite, make sure you’ve created a database by this point. Do that with CREATE DATABASE database_name; within your database’s interactive prompt.

...

If you’re using SQLite, you don’t need to create anything beforehand - the database file will be created automatically when it is needed.

关于django - 让django在 "migrate"上自动创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40802165/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com