Python Operation Memcache/redis/rabbitmq

Source: Internet
Author: User
Tags connection pooling rabbitmq

Database operations:
-Database
-table
A. single table

B. One-to-many
user type:
1 Super User
2 Normal user
32 user
User:
Way 3 (set number, constraint = foreign key (table, column )
Liu Hao 6
He Lei 3
He Lei 3


C. Many-to-many
hosts: Host name ....
1 c1.com
2 c1.com
3 c1.com
4 c1.com

User table: User name ....
1 yan Breeding
2 lo Rao
3 Muddy
4 use three

Install B:
User host Time
4 1,
4 2,
4 1,
4 2,
3 2,


Blind Date:
1 Strict breeding
2 Lu Rao
3 Muddy
4 use three


Record:
Unisex
4 3 ()
4 3
4 2
1 3

+ Union UNIQUE constraint: (male and female) br>-Data Manipulation
Add
INSERT into TB (name,age) VALUES (' root ', +)
Delete
Delete from TB where ID > 1
Change
Update TB Set age=73 where name= ' Alex '
Check
Select * from TB;
SELECT * from TB where ID >
Select nid,username,pwd from TB where ID >

-pymysql
1. Execute (' Sele CT * from terabytes where name=%s ', ' root ')
2. Execute ("SELECT * from TB"); Fetchone ...
3. [(1,root,19), (2,root,19),]
[{},{},]
4. Lastrowid get the self-increment ID value


1. mysql Supplement
GROUP BY
-Aggregate sum (SID), Max (SID), Min (SID), COUNT (SID) for the column
-Aggregation condition filtering, having count (SID) > 7

Even table operation
-INNER JOIN: null not present
-LEFT JOIN: How many shows how many, even the table has no corresponding entry: null
-Right Join

Ps:
Fk:
-Save Save
-Slow query
Pros: Easy for programmers

No FK:
-Storage does not save
-Fast Query
Advantages: Fast Query
Cons: Programmers maintain data

Django: A magical double-down route

Exercises:
Http://www.cnblogs.com/wupeiqi/articles/5729934.html
Http://www.cnblogs.com/wupeiqi/articles/5748496.html


2. Memcached
Service side:
Software on a remote server, manipulating data in memory
Dictionary: {
K: "Asdfasdf",
K: "Asdfasdf",
}
Client
Connection:
Python-memcached
Pylibmc

3. Redis

{
K1: "Asdfasdf", String strings
K2:[1,2,1,2],list List
k3:{' K1 ': 1, ' K2 ': 2},hash dictionary
k4:{1,2,4,5,1,}, collection
k5:{(1,60), (2,70), (3,6)}, ordered collection
}


1. Connect
2. Connection pooling
Pool = Redis. ConnectionPool (host= ' 10.211.55.4 ', port=6379, max_connections=10)
conn = Redis. Redis (Connection_pool=pool)
3. Support Transactions
4. Publishing and subscribing

4. RabbitMQ


Exchange ==>


Rpc





Python Operation Memcache/redis/rabbitmq

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.