使用uliweb里面的數據庫操作函數。
安裝uliweb后,引用orm。
~~~
#coding=utf-8
from uliweb.orm import *
~~~
### 鏈接數據庫[?](http://uliweb.clkg.org/tutorial/view_chapter/189#title_0-0-1)
~~~
db=get_connection('mysql://root:root@localhost/mail?charset=utf8')
~~~
### 表和字段[?](http://uliweb.clkg.org/tutorial/view_chapter/189#title_0-0-2)
~~~
class test(Model):
testname = Field(str)
dt = Field(datetime.datetime)
status = Field(str)
~~~
描述字段中,str 最大長度的例子;
~~~
name = Field(str, max_length=8096)
~~~
### 在庫里面建立表[?](http://uliweb.clkg.org/tutorial/view_chapter/189#title_0-0-3)
~~~
db.metadata.create_all()
~~~
### 新加一條記錄[?](http://uliweb.clkg.org/tutorial/view_chapter/189#title_0-0-4)
~~~
n = test()
n.testname="jeapedu"
n.status="0"
n.save()
~~~
### 更改一條記錄[?](http://uliweb.clkg.org/tutorial/view_chapter/189#title_0-0-5)
~~~
n = test.get(test.c.status=="0")
n.update(status="1")
n.save()
~~~
### 讀取所有內容[?](http://uliweb.clkg.org/tutorial/view_chapter/189#title_0-0-6)
~~~
test.all()
~~~
參考網址:?[https://github.com/limodou/uliweb/blob/master/test/test_orm.py](https://github.com/limodou/uliweb/blob/master/test/test_orm.py)
文檔地址:?[http://limodou.github.io/uliweb-doc/zh_CN/orm.html](http://limodou.github.io/uliweb-doc/zh_CN/orm.html)
- Python爬蟲入門
- (1):綜述
- (2):爬蟲基礎了解
- (3):Urllib庫的基本使用
- (4):Urllib庫的高級用法
- (5):URLError異常處理
- (6):Cookie的使用
- (7):正則表達式
- (8):Beautiful Soup的用法
- Python爬蟲進階
- Python爬蟲進階一之爬蟲框架概述
- Python爬蟲進階二之PySpider框架安裝配置
- Python爬蟲進階三之Scrapy框架安裝配置
- Python爬蟲進階四之PySpider的用法
- Python爬蟲實戰
- Python爬蟲實戰(1):爬取糗事百科段子
- Python爬蟲實戰(2):百度貼吧帖子
- Python爬蟲實戰(3):計算大學本學期績點
- Python爬蟲實戰(4):模擬登錄淘寶并獲取所有訂單
- Python爬蟲實戰(5):抓取淘寶MM照片
- Python爬蟲實戰(6):抓取愛問知識人問題并保存至數據庫
- Python爬蟲利器
- Python爬蟲文章
- Python爬蟲(一)--豆瓣電影抓站小結(成功抓取Top100電影)
- Python爬蟲(二)--Coursera抓站小結
- Python爬蟲(三)-Socket網絡編程
- Python爬蟲(四)--多線程
- Python爬蟲(五)--多線程續(Queue)
- Python爬蟲(六)--Scrapy框架學習
- Python爬蟲(七)--Scrapy模擬登錄
- Python筆記
- python 知乎爬蟲
- Python 爬蟲之——模擬登陸
- python的urllib2 模塊解析
- 蜘蛛項目要用的數據庫操作
- gzip 壓縮格式的網站處理方法
- 通過瀏覽器的調試得出 headers轉換成字典
- Python登錄到weibo.com
- weibo v1.4.5 支持 RSA協議(模擬微博登錄)
- 搭建Scrapy爬蟲的開發環境
- 知乎精華回答的非專業大數據統計
- 基于PySpider的weibo.cn爬蟲
- Python-實現批量抓取妹子圖片
- Python庫
- python數據庫-mysql
- 圖片處理庫PIL
- Mac OS X安裝 Scrapy、PIL、BeautifulSoup
- 正則表達式 re模塊
- 郵件正則
- 正則匹配,但過濾某些字符串
- dict使用方法和快捷查找
- httplib2 庫的使用