微型博客系统 - 数据库课程设计任务1
======
这是一个微型博客系统,具备创建、删除、修改及查询帖子的功能。
在线演示地址: http://47.93.240.135:5000/blog/
开发环境与技术说明
------
**开发语言**
开发语言选用当前最火热的[Python](https://www.python.org/)语言。Python是一个解释型脚本语言,由于具有规范的格式,使得Python代码非常美观、简洁。在加上Python自带的各种Web框架,如 `Flask`、`Fjango`, 开发人员能在短时间内迅速开发出强大的Web应用。总之,使用Python写代码的感觉非常爽。
**Web服务器**
本系统选用Python的`Django`库作为后端框架,`Django`自带了一个简单的Web服务器。因为该系统仅作为练习用,故没必要采用`Ngnix`等专业的Web服务器。
**数据库管理系统**
数据库采用`SQLite`数据库。`SQLite`是一个轻量级的关系型数据库,由于数据保存在单个文件中,这使得SQLite无需安装或配置即可食用。另外,其底层实现采用C语言,因此体积小且性能强大。
数据库操作接口采用Python内置的的`sqlite3`模块,它提供类似`JDBC`的API用于访问`SQLite`数据库。
数据库表的定义
------
Table Name: posts
| column | type | info | description |
|---|---|---|---|
| id | INTEGER | primary key | Post's id |
| title | TEXT | | Post's title |
| text | TEXT | | Post's text content |
| timestamp | TEXT | | Post's create date time |
SQL commands to create table:
```
CREATE TABLE posts (
id INTEGER PRIMARY KEY,
title TEXT,
text TEXT,
timestamp TEXT
);
```
数据库连接与增删改查
-------
以下为Python语法示例:
```python
import sqlite3
# connect
conn = sqlite.connect("my_database.sqlite3")
# get cursor
cursor = conn.cursor()
# create tables
sql_command = """
CREATE TABLE posts (
id INTEGER PRIMARY KEY,
title TEXT,
text TEXT,
timestamp TEXT);
"""
cursor.execute(sql_command)
# Create
cursor.execute('INSERT INTO posts(title, text, timestamp) values ("Title", "Text", "Time")')
# Read
result = cursor.execute('SELECT * FROM posts')
for post in result.fetchall():
print(post)
# Update
cursor.execute('UPDATE posts SET title="A", text="B" where id=1')
# Delete
cursor.execute("DELETE FROM posts where id=1")
```
功能截图
-------
![](https://github.com/fondoger/Micro-Blog-System/raw/master/screenshots/together.jpg)
更多截图文件保存在`screenshots`目录下。
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计:基于 Python and Django的微型博客系统.zip (47个子文件)
Graduation Design
screenshots
WeChat Image_20181006191500.png 60KB
WeChat Image_20181006191512.png 57KB
together.jpg 294KB
WeChat Image_20181006191453.png 111KB
manage.py 538B
实验报告.pdf 239KB
blog
__init__.py 0B
tests.py 60B
admin.py 63B
migrations
__init__.py 0B
__pycache__
__init__.cpython-35.pyc 134B
apps.py 83B
models.py 57B
templates
blog
post_edit.html 3KB
post.html 938B
feed-item.html 1KB
base.html 2KB
index.html 729B
backup_post_edit.html 4KB
urls.py 369B
management
__init__.py 0B
commands
__init__.py 0B
init_database.py 2KB
__pycache__
init_database.cpython-35.pyc 2KB
__init__.cpython-35.pyc 141B
__pycache__
__init__.cpython-35.pyc 132B
__pycache__
db_init_script.cpython-35.pyc 1KB
admin.cpython-35.pyc 168B
__init__.cpython-35.pyc 123B
urls.cpython-35.pyc 477B
views.cpython-35.pyc 5KB
models.cpython-35.pyc 165B
static
blog
post.css 63KB
base.css 39KB
index.css 13KB
post_edit.css 44KB
views.py 4KB
data.sqlite3 6KB
README.md 2KB
mysite
__init__.py 0B
wsgi.py 389B
urls.py 798B
settings.py 3KB
__pycache__
settings.cpython-35.pyc 2KB
__init__.cpython-35.pyc 125B
urls.cpython-35.pyc 975B
wsgi.cpython-35.pyc 544B
共 47 条
- 1
资源评论
学术菜鸟小晨
- 粉丝: 1w+
- 资源: 4928
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功