首先需要配置sqlite3
官方现在sqlite3压缩包,将其解压到某一文件夹中,然后在系统的环境变量中配置sqlite3,
由于在Django的项目文件夹目录下,有db.sqlite3文件,所以需要要访问该数据,需要在dos中键入下入命令,
sqlite3 db.sqlite3
进入数据库之后,即可使用sql语句进行访问
select * from dbname
SELECT name FROM sqlite_master
WHERE type='table'ORDER BY name;
select * from upload_user;
to insert a column in the models.py
password = CharField(max_length= 30)python manage.py shell
from django.db import connection
cursor = connection.cursor()
cursor.execute('alter table upload_user add column password varchar(30)')
python manage.py makemigrations
python manage.py migrate
本文介绍了如何配置SQLite3数据库并使用它与Django项目进行交互。包括将SQLite3添加到系统环境变量、通过命令行访问Django项目的数据库、执行SQL语句查询表信息以及修改数据库表结构的方法。
2920

被折叠的 条评论
为什么被折叠?



