随笔分类 -  编程语言 / python

摘要:1、通过语言特性实现: 2、通过第三方库实现: pip install retry 参数介绍: 案例: 参考:https://pypi.python.org/pypi/retry https://stackoverflow.com/questions/2083987/how-to-retry-aft 阅读全文
posted @ 2017-10-27 12:25 bigbigtree 阅读(6932) 评论(1) 推荐(0)
摘要:刚刚配置好TileCache,准备开工。期间碰到多种配置的问题,罗列一下。1、mod_python的一个最主要优点就是在性能上超越传统CGI。所以使用mod_python替代CGI。前提是安装好apache和python。由于在windows(win7 64)平台下搭建环境,下载的mod_python-3.3.1.win32-py2.5-Apache2.2.exe,没有出现选择apache安装目录的对话框。试了多多种方法不成功,下载mod_python-3.3.1.win32-py2.4-Apache2.2.exe后,终于成功。2、配置TileCache时,需要在Python的sys.path 阅读全文
posted @ 2013-10-11 14:48 bigbigtree 阅读(967) 评论(0) 推荐(0)
摘要:PYTHONPATH是Python搜索路径,默认我们import的模块都会从PYTHONPATH里面寻找。 使用下面的代码可以打印PYTHONPATH:print(os.sys.path) 我的某个项目的PYTHONPATH如下:[ 'D:\\Python3\\workspace\\PythonLab\\src', 'D:\\aptana3\\plugins\\org.python.pydev_2.7.0.2012080220\\pysrc', 'D:\\Python3\\python33.zip', 'D:\\Python3\\DLLs 阅读全文
posted @ 2013-10-10 21:43 bigbigtree 阅读(3841) 评论(0) 推荐(0)
摘要:最近做一些数据库调研的工作,目标是实现影像更快的入库、出库、查询,并实现并行访问等操作。将结果总结成一个mysqlImg类。关于mongodb的图像存储,参见http://www.cnblogs.com/bigbigtree/p/3242483.html关于mysql&python的问题和mysql... 阅读全文
posted @ 2013-08-11 21:16 bigbigtree 阅读(6510) 评论(0) 推荐(0)
摘要:Class cursor.MySQLCursorBuffered该类从Class cursor.MySQLCursorBuffered继承,如果需要,可以在执行完SQL语句后自动缓冲结果集合。import mysql.connectorcnx = mysql.connector.connect()# Only this particular cursor will buffer resultscnx.cursor(buffered=True)# All cursors will be buffering by defaultcnx2 = mysql.connector.connect(buff 阅读全文
posted @ 2013-08-09 13:57 bigbigtree 阅读(2209) 评论(0) 推荐(0)
摘要:Class cursor.MySQLCursor具体方法和属性如下:Constructor cursor.MySQLCursorMethod MySQLCursor.callproc(procname, args=())Method MySQLCursor.close()Method MySQLCursor.execute(operation, params=None, multi=False)Method MySQLCursor.executemany(operation, seq_params)Method MySQLCursor.fetchall()Method MySQLCursor. 阅读全文
posted @ 2013-08-09 10:06 bigbigtree 阅读(5813) 评论(0) 推荐(0)
摘要:mysql官网关于python的API是最经典的学习材料,相信对于所有函数浏览一遍以后,Mysql数据库用起来一定得心应手。首先看一下Connector/Python API包含哪些类和模块。Module mysql.connector Class connection.MySQLConnectio... 阅读全文
posted @ 2013-08-08 21:11 bigbigtree 阅读(7484) 评论(0) 推荐(0)
摘要:首先对于数据库的基本操作要有一定基础,其次了解Python的基础语法。建议先阅读MysqL中文教程http://doc.mysql.cn/mysql5/refman-5.1-zh.html-chapter/和Python基础教程。一、python连接Mysql连接MySQL的方法有多种,如MySQLdb http://sourceforge.net/projects/mysql-python/但是该项目并不支持python3。现在Mysql官方已经提供了python的连接接口Connector/Python,有安装方法和文档。Connector/Python安装地址:http://dev.my 阅读全文
posted @ 2013-08-08 20:59 bigbigtree 阅读(1728) 评论(0) 推荐(0)
摘要:连接mysql数据库:cnx = mysql.connector.connect(user='joe', database='test') Connector/Python参数列表Argument NameDefaultDescriptionuser(username*)The user name used to authenticate with the MySQL server.password(passwd*)The password to authenticate the user with the MySQL server.database(db*)T 阅读全文
posted @ 2013-08-08 11:05 bigbigtree 阅读(543) 评论(0) 推荐(0)
摘要:最近做一些数据库调研的工作,目标是实现影像更快的入库、出库、查询,并实现并行访问等操作。将结果总结成一个mongoImg类,也算是小结吧。 1 ''' 2 Created on 2013-8-6 3 class mongoInsert 4 @author: tree 5 ''' 6 __metacl... 阅读全文
posted @ 2013-08-07 09:59 bigbigtree 阅读(10011) 评论(6) 推荐(0)
摘要:将一个py脚本从Centos转到win运行,出错如下:UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence虽然明白是编码的问题,网络上decode()什么的,貌似不适用python3。后来发现使用字节方式打开可以。出错函数如下:gridfs.GridFS.put()函数。其中调用了读写操作If you want raw bytes then you need to open it in binary mode.pipe = open 阅读全文
posted @ 2013-08-05 16:19 bigbigtree 阅读(19147) 评论(3) 推荐(0)