python 以nosql方式连接mysql handlersocket插入操作获得变量值_MySQL
程序员文章站
2022-06-16 14:00:33
...
python
bitsCN.com
ubuntu11.10安装mysql+handlersocket
http://www.cnblogs.com/aaronwxb/archive/2012/04/29/2475834.html
何为pyhs?简单来说,就是封装了接口,实现python以nosql方式连接mysql数据库,对数据库进行一些操作。
pyhs is a pure Python client (with optional C speedups) for HandlerSocket plugin to MySQL database. In short, it provides access to the data omitting the SQL engine in a NoSQL-like interface. It allows all simple operations (get, insert, update, delete) over indexed data to perform considerably faster than by usual means.
安装方法:
http://packages.python.org/python-handler-socket/installation.html
简明教程:
http://packages.python.org/python-handler-socket/usage.html
进入主题,在update操作时,使用变量是没错的:
1 from pyhs import Manager 2 3 attendant_id = '222' 4 newname = 'wxb' 5 newpwd = '123456' 6 7 hs = Manager() 8 name = '2a' 9 10 data=hs.update('final','kf_attendant','=',['AD_ID','AD_Name','AD_Password'],[attendant_id],[attendant_id,newname,newpwd],None,1,0,True)
但是进行insert操作时,直接使用变量名就一直出错“SystemError: NULL result without error in PyObject_Call”,结果使用str()函数解决了~
1 from pyhs import Manager 2 import uuid 3 4 hs = Manager() 5 6 newid = uuid.uuid1() 7 newname = 'aaa' 8 newpwd = '123' 9 10 hs.insert('final','kf_attendant',[('AD_ID',str(newid)),('AD_Name',str(newname)),('AD_Password',str(newpwd))])bitsCN.com