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 ...
随机推荐
- Spark特征(提取,转换,选择)extracting, transforming and selecting features
VectorAssembler字段转换成特征向量 import org.apache.spark.ml.feature.VectorAssembler val colArray = Array(&qu ...
- Centos7搭建vsftp服务器
环境查看 安装vsftp软件 yum -y install vsftpd 修改配置文件/etc/vsftpd/vsftpd.conf (其余配置保持默认即可) anonymous_enable=NO ...
- poj3417Network【LCA】【树形DP】
Yixght is a manager of the company called SzqNetwork(SN). Now she's very worried because she has jus ...
- IntelliJ IDEA学习记录
一.下载 地址:官网下载地址 二.安装 运行安装程序,一路下一步.注意选择安装路径. 三.基本概念 project:相当于donet中的解决方案(solution),eclipse中的工作空间(wor ...
- postgreSQL 自增需要使用序列
postgreSQL 自增需要使用序列 1.使用SERIAL CREATE TABLE users ( id SERIAL4 primary key , name character varying, ...
- SpringBoot @Transactional声明事务无效问题
查看系统支持的存储引擎:show engines; 查看表使用的引擎:show table status from db_name where name='table_name'; 修改表引擎方法: ...
- Lodash 中文文档 (v4.16.1) 手机版
http://lodash.swift.ren/ 手机扫描二维码直接进入
- 【剑指offer】 二叉树中和为某一值的路径
一.题目: 输入一颗二叉树的跟节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径.路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径.(注意: 在返回值的list中,数组长度 ...
- 十四、springboot全局处理异常(@ControllerAdvice + @ExceptionHandler)
1.@ControllerAdvice 1.场景一 在构建RestFul的今天,我们一般会限定好返回数据的格式比如: { "code": 0, "data": ...
- [lr] 基本色调调整和色调曲线
基本色调调整 • 曝光度调整 ▶ 控制区域 在Lightroom中,软件提示我们曝光控制的是如图中间调的区域.我们把鼠标移动到曝光工具条上,软件会提示我们这个区域: ▶ 实际效果 ▪ 增加曝光值 增加 ...