python操作memcache/redis/rabbitmq

來源:互聯網
上載者:User

標籤:補充   memcache   儲存   logs   exe   list   使用者名稱   服務端   value   

資料庫操作:
- 資料庫
- 表
a. 單表

b. 一對多
使用者類型:
1 超級使用者
2 普通使用者
3 二筆使用者
使用者:
方式器 3(設定數字,約束=外鍵(表,列))
劉浩 6
何磊 3
何磊 3


c. 多對多
主機:主機名稱 ....
1 c1.com
2 c1.com
3 c1.com
4 c1.com

使用者表:使用者名稱 ....
1 嚴選育
2 盧饒
3 泥濘
4 利用三

裝B:
使用者 主機 時間
4 1 83
4 2 83
4 1 93
4 2 93
3 2 93


相親:
1 嚴選育
2 盧饒
3 泥濘
4 利用三


記錄:
男 女
4 3()
4 3
4 2
1 3

+聯合唯一約束:(男 女 )
- 資料操作

insert into tb(name,age) values(‘root‘,18)

delete from tb where id > 1

update tb set age=73 where name=‘alex‘

select * from tb;
select * from tb where id > 10
select nid,username,pwd from tb where id > 10

- pymysql
1. execute(‘select * from tb where name=%s‘,‘root‘)
2. execute("select * from tb "); fetchone...
3. [(1,root,19),(2,root,19),]
[{},{},]
4. lastrowid 擷取自增的ID值


1. MySQL補充
group by
- 對列進行彙總 sum(sid),max(sid),min(sid),count(sid)
- 彙總條件過濾,having count(sid) > 7

連表操作
- inner join: 不會出現null
- left join :左側,有多少顯示多少,連表無對應項:null
- right join

PS:
FK:
- 儲存省
- 查詢慢
優點:程式員省事

No FK:
- 儲存不省
- 查詢快
優點:查詢快
缺點:程式員維護資料

Django:神奇的雙下劃綫

練習題:
http://www.cnblogs.com/wupeiqi/articles/5729934.html
http://www.cnblogs.com/wupeiqi/articles/5748496.html


2. Memcached
服務端:
遠程伺服器上的軟體,在記憶體中操作資料
字典:{
k:"asdfasdf",
k:"asdfasdf",
}
用戶端
串連:
python-memcached
pylibmc

3. redis

{
k1:"asdfasdf",string 字串
k2:[1,2,1,2],list 列表
k3:{‘k1‘:1,‘k2‘:2},hash字典
k4:{1,2,4,5,1,},集合
k5:{(1,60),(2,70),(3,6)},有序集合
}


1. 串連
2. 串連池
pool = redis.ConnectionPool(host=‘10.211.55.4‘, port=6379, max_connections=10)
conn = redis.Redis(connection_pool=pool)
3. 支援事務
4. 發布和訂閱

4. RabbitMQ


exchange ==>


RPC




 


python操作memcache/redis/rabbitmq

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.