08 2013 档案
摘要:error C2504:头文件包含不全今天碰到了很烦的问题,继承一个类之后,感觉头文件都包含了,可还是出现父类未定义的问题,最后发现,子类的子类在实现时,需要在cpp文件中包含所有他的父类的定义。因为每个cpp文件是单独编译的,需要知道其所有父类来确定这个类的大小和实现的细节。实例代码如下://a.hclass A{public: virtual void fun()=0;};//b.hclass B : public A{public: virtual void fun();};//b.cpp#include "a.h"void B::fun(){ std::cout&l
阅读全文
摘要:转自http://www.cnblogs.com/yishuiliunian/archive/2011/03/18/1988244.html上次腾讯面试,问我int和long分别几个字节,结果被鄙视了。事过N天,鼓起勇气来好好查了一下,发现学问还是蛮大的。int类型比较特殊,具体的字节数同机器字长和编译器有关。如果要保证移植性,尽量用__int16 __int32 __int64吧,或者自己typedef int INT32一下。C、C++标准中只规定了某种类型的最小字节数(防止溢出)64位指的是cpu通用寄存器的数据宽度是64位的。找到一个图数据类型名称字节数别名取值范围int*signed
阅读全文
摘要:最近做一些数据库调研的工作,目标是实现影像更快的入库、出库、查询,并实现并行访问等操作。将结果总结成一个mysqlImg类。关于mongodb的图像存储,参见http://www.cnblogs.com/bigbigtree/p/3242483.html关于mysql&python的问题和mysql...
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文
摘要:mysql官网关于python的API是最经典的学习材料,相信对于所有函数浏览一遍以后,Mysql数据库用起来一定得心应手。首先看一下Connector/Python API包含哪些类和模块。Module mysql.connector Class connection.MySQLConnectio...
阅读全文
摘要:首先对于数据库的基本操作要有一定基础,其次了解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
阅读全文
摘要:连接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
阅读全文
摘要:BLOB是一个二进制大对象,可以容纳可变数量的数据。有4种BLOB类型:TINYBLOB、BLOB、MEDIUMBLOB和LONGBLOB。它们只是可容纳值的最大长度不同。A binary large object that can hold a variable amount of binary data. The sorting and comparison of the values for these objects is performed in case-sensitive manner.TINYBLOBA binary large object column with a max
阅读全文
摘要:最近做一些数据库调研的工作,目标是实现影像更快的入库、出库、查询,并实现并行访问等操作。将结果总结成一个mongoImg类,也算是小结吧。 1 ''' 2 Created on 2013-8-6 3 class mongoInsert 4 @author: tree 5 ''' 6 __metacl...
阅读全文
摘要:将一个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
阅读全文
摘要:混淆了 python2 里边的 str 和 unicode 数据类型。1.对需要 str->unicode 的代码,可以在前边写上import sysreload(sys)sys.setdefaultencoding('utf8')把 str 编码由 ascii 改为 utf8 (或 gb18030)2.python3 区分了 unicode str 和 byte arrary,并且默认编码不再是 ascii
阅读全文
摘要:eclipse emacs 插件http://www.mulgasoft.com/emacspluseclipse字体设置:一、把字体设置为Courier New操作步骤:打开Elcipse,点击菜单栏上的“Windows”——点击“Preferences”——点击“Genneral”——点击“Appearance”——点击“Colors and Font”——在右侧框展开“Basic”文件夹--双击“Text Font”——在弹出窗选择“Courier New”(注:这里可能找不到“Courier New”,点击字体选择框左下角的“显示更多字体”链接来打开设置字体的控制面板,找到“Couri
阅读全文
摘要:安装mongohttp://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/其中修改:echo logpath=C:\mongodb\log\mongo.log > C:\mongodb\mongod.cfg此命令行用来配置mongodb安装,创建文件夹mk C:\mongodb\data\dbmk C:\mongodb\log编辑mongod.cfg如下:##store data heredbpath=C:\mongodb\data\db##all output go herelogpath=C:\mongodb\
阅读全文