python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法
python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法
window安装redis,下载Redis的压缩包
https://github.com/dmajkic/redis/downloads
如redis-2.4.5-win32-win64.zip
下载完后将其解压放在自己要放的目录下
如果你是32位的话就进32bit的文件夹,64位就进64bit文件夹
文件夹进去后会看到几个文件:
redis-benchmark.exe: 性能测试 模拟N个客户端发送set,get请求
redis-check-aof.exe:更新日志检查
redis-check-dump.exe:本地数据库检查
redis-server.exe:服务程序
打开dos命令栏,进入到redis的目录下面(如D:\redis),输入以下命令:
C:\Users\Administrator>d:
D:\>cd redis
D:\redis>redis-server.exe redis.conf
[5184] 22 Jul 15:53:53 * Server started, Redis version 2.4.5
[5184] 22 Jul 15:53:53 * DB loaded from disk: 0 seconds
[5184] 22 Jul 15:53:53 * The server is now ready to accept connections on port 6
379
启动成功(注:不需要安装,关闭命令栏就相当于关闭redis服务了,下次启动需要重新执行上面命令)
然后再打开一个dos命令栏,进入到redis的目录下,输入以下命令:
D:\redis>redis-cli.exe -h 127.0.0.1 -p 6379
进入到redis环境,测试一下set get命令:
redis 127.0.0.1:6379> set zdz helloredis
OK
redis 127.0.0.1:6379> get zdz
"helloredis"
redis 127.0.0.1:6379> set arr "{'aa':1122,'bb':444}"
OK
redis 127.0.0.1:6379> keys *
1) "zdz"
2) "arr"
--------------------------------
set key value 存值
get key 取值
=========================================
#redis_class.py
import redis,json
class Credis(object):
def __init__(self):
self.pool = redis.ConnectionPool(host='localhost', port=6379, db=0, socket_timeout=4)
def setRedis(self,key, err, status, msg):
result = redis.Redis(connection_pool=self.pool)
redisValue = {'err':err,'status':status,'msg':msg}
redisValue = json.dumps(redisValue)
return result.set(key,redisValue)
def getRedis(self,key):
result = redis.Redis(connection_pool=self.pool)
return result.get(key)
credis = Credis()
使用例子:
from redis_class import credis
credis.setRedis('key',0,1,'set')
=========================================
Parser安装
Parser可以控制如何解析redis响应的内容。redis-py包含两个Parser类,PythonParser和HiredisParser。默认,如果已经安装了hiredis模块,redis-py会使用HiredisParser,否则会使用PythonParser。
HiredisParser是C编写的,由redis核心团队维护,性能要比PythonParser提高10倍以上,所以推荐使用。
使用easy_install命令安装:easy_install hiredis
=========================================
pycharm 增加 redis 支持
用pip安装redis比较顺利
D:\Python27>pip install redis
让pycharm ide上支持import redis不报错的方法:
在pycharm里 File -> Settings -> Python interpreter
进入到Python interpreter 点击+按钮 搜索redis 选择一个安装就可以了。
使用python+redis实现实时聊天室--pythoner.org
http://pythoner.org/wiki/701/
===========================================
安装MySQL-python报错比较多,但不关mysql的事
Windows下安装MySQLdb遇到的问题及解决方法
>pip install MySQL-python
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).
Get it from http://aka.ms/vcpython27
----------------------------------------
按上面提示到http://aka.ms/vcpython27下载安装后执行VCForPython27.msi后仍然报下面的错误:
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':
No such file or directory
error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\
Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit
status 2
---------------------------------------
解决办法:搜索或者到下面网址下载安装:MySQL-python-1.2.3.win-amd64-py2.7.exe
MySQL-python 1.2.3 for Windows and Python 2.7, 32bit and 64bit versions | codegood
http://www.codegood.com/archives/129
安装后再用pip命令提示已经安装了
C:\Users\Administrator>pip install MySQL-python
Requirement already satisfied (use --upgrade to upgrade): MySQL-python in d:\pyt
hon27\lib\site-packages
在pycharm里 File -> Settings -> Python interpreter 里面添加MySQL-python就可以了
=======================================
下面是设置的截图:

使用实例代码请看本人另外一篇博客:
python3.4学习笔记(二十五) Python 调用mysql redis实例代码 - 流风,飘然的风 - 博客园
http://www.cnblogs.com/zdz8207/p/python_learn_note_25.html
python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法的更多相关文章
- python3.4学习笔记(二十五) Python 调用mysql redis实例代码
python3.4学习笔记(二十五) Python 调用mysql redis实例代码 #coding: utf-8 __author__ = 'zdz8207' #python2.7 import ...
- python3.4学习笔记(二十六) Python 输出json到文件,让json.dumps输出中文 实例代码
python3.4学习笔记(二十六) Python 输出json到文件,让json.dumps输出中文 实例代码 python的json.dumps方法默认会输出成这种格式"\u535a\u ...
- python3.4学习笔记(二十二) python 在字符串里面插入指定分割符,将list中的字符转为数字
python3.4学习笔记(二十二) python 在字符串里面插入指定分割符,将list中的字符转为数字在字符串里面插入指定分割符的方法,先把字符串变成list然后用join方法变成字符串str=' ...
- python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法
python3.4学习笔记(二十) python strip()函数 去空格\n\r\t函数的用法 在Python中字符串处理函数里有三个去空格(包括'\n', '\r', '\t', ' ')的函数 ...
- (C/C++学习笔记) 二十四. 知识补充
二十四. 知识补充 ● 子类调用父类构造函数 ※ 为什么子类要调用父类的构造函数? 因为子类继承父类,会继承到父类中的数据,所以子类在进行对象初始化时,先调用父类的构造函数,这就是子类的实例化过程. ...
- Java基础学习笔记二十四 MySQL安装图解
.MYSQL的安装 1.打开下载的mysql安装文件mysql-5.5.27-win32.zip,双击解压缩,运行“setup.exe”. 2.选择安装类型,有“Typical(默认)”.“Compl ...
- Java学习笔记二十四:Java中的Object类
Java中的Object类 一:什么是Object类: Object类是所有类的父类,相当于所有类的老祖宗,如果一个类没有使用extends关键字明确标识继承另外一个类,那么这个类默认继承Object ...
- PHP学习笔记二十四【Get Set】
<?php Class Person{ private $n1; private $n2; private $n3; //使用__set方法来管理所有的属性 public function __ ...
- angular学习笔记(二十四)-$http(2)-设置http请求头
1. angular默认的请求头: 其中,Accept 和 X-Requested-With是$http自带的默认配置 Accept:application/json,text/plain ...
随机推荐
- layerui如何隐藏按钮?
https://www.layui.com/doc/modules/layer.html#btn 建议把 btn: ['取消'],btnAlign: 'c',yes: function (index) ...
- Elasticsearch 不同的搜索类型之间的区别
1.match 轻量级搜索 GET /wymlib/_search { "query": { "match": { "title": ...
- np.tile 函数使用
>>> import numpy>>> numpy.tile([0,0],5)#在列方向上重复[0,0]5次,默认行1次array([0, 0, 0, 0, 0, ...
- Luogu 3373 - 【模板】线段树 2 - [加乘线段树]
题目链接:https://www.luogu.org/problemnew/show/P3373 题目描述 如题,已知一个数列,你需要进行下面三种操作: 1.将某区间每一个数乘上x 2.将某区间每一个 ...
- CodeForces - 950D A Leapfrog in the Array 玄学题
题意:n个数1~n(n<=1e18)依次放在一个数组中,第i个数位置为2i-1,其它地方是空的.现在重复以下操作:将最右边的数放到离其左边最近的空的位置,直到所有数移到前一半的位置中.有q< ...
- flume学习笔记
#################################################################################################### ...
- linux:用户及文件权限管理
学习内容来自实验楼.莫烦python.CSDN 一.Linux 用户管理 1. 查看用户 who am i 或者who mom likes who -a:打印所有能打印的 who -d :打印死掉的 ...
- count(*) count(1) count(column)区别
count(*) 和count(1)的效果是一样的.在某些情况下效率不一样.也会统计包含null的记录. count(column)会返回当前字段不为null的记录数.
- QS Network---zoj1586最小生成树
Description Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In th ...
- Git使用常见问题脚本
receive.denyCurrentBranch 这是由于git默认拒绝了push操作,需要进行设置,修改.git/config添加如下代码: [receive] denyCurrentBr ...