带有 Django 的 SQLite 3 数据库 [英] SQLite 3 Database with Django
问题描述
我被困在关于显示 SQLite 表的 Django 文档教程中.
" 如果您有兴趣,请为您的数据库运行命令行客户端并键入 \dt (PostgreSQL)、SHOW TABLES; (MySQL) 或 .schema (SQLite) 以显示 Django 创建的表.">
我创建了一个名为 mysite 的项目.位置:C:\Python34\Scripts\mysite
在mysite
里面,有mysite
文件夹、db.sqlite3
和manage.py
.>
我打开了命令提示符并导航到 C:\Python34\Scripts\mysite
并输入 .schema
并返回.schema 无法识别.."
我的settings.py
数据库文件:
DATABASES = {'默认':{'引擎':'django.db.backends.sqlite3','NAME': os.path.join('BASE_DIR', 'db.sqlite3'),}}
我也无法定义 BASE_DIR.我不知道 db.sqlite3
文件.我不知道文件是否是 .db 扩展名.
有人可以帮我找出来吗?
.schema 是一个命令,您可以在 sqlite3 命令行界面内运行以获取该数据库中的表列表.
如果你还没有安装它,你可以在这里下载 sqlite3 命令行界面并安装它:https://www.sqlite.org/download.html
安装 sqlite3 后,您可以:
将目录更改为包含 sqlite3 数据库文件的文件夹
cd C:\Python34\Scripts\mysite
用sqlite3命令行界面打开数据库文件
sqlite3 db.sqlite3
在 sqlite3 命令行界面提示符下键入 .schema 获取表列表
.schema
I am stuck on Django Documentation tutorial on displaying SQLite table.
" If you’re interested, run the command-line client for your database and type \dt (PostgreSQL), SHOW TABLES; (MySQL), or .schema (SQLite) to display the tables Django created. "
I have created a project named mysite. Location : C:\Python34\Scripts\mysite
Inside mysite
, there are mysite
folder, db.sqlite3
, and manage.py
.
I opened command prompt and navigate to C:\Python34\Scripts\mysite
and I type .schema
and it returns " . schema is not recognized.. "
My settings.py
database file :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join('BASE_DIR' , 'db.sqlite3'),
}
}
I also can't define BASE_DIR. I don't know about the db.sqlite3
file. I cannot know if the file is .db extension.
Could someone help me to find out ?
.schema is a command you would run inside of the sqlite3 command line interface to get a list of tables in that database.
If you don't already have it installed, you can download sqlite3 command line interface here and install it: https://www.sqlite.org/download.html
Once you have sqlite3 installed, you can:
Change directories to the folder containing your sqlite3 database file
cd C:\Python34\Scripts\mysite
Open the database file with the sqlite3 command line interface
sqlite3 db.sqlite3
Get a list of tables by typing .schema at the sqlite3 command line interface prompt
.schema
这篇关于带有 Django 的 SQLite 3 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!