python使用pymysql数据库操作类

技术探讨  2018-03-29 16:22   7775 python pymysql
# -*- encoding: UTF-8 -*-
#!/usr/bin/env python3
# filename crawl.py
import rocdb
# rocdb.RocDb(host,user,password,database)
dbo = rocdb.RocDb('localhost','root','root','test')
# insert(table_name,data) 新增数据
dbo.insert('employee',('Macsa3465', 'Mohan', 40, 'M', 2000))
# batch insert   批量新增
dbo.insert('employee',[
    ('Macsa3465', 'Mohan', 40, 'M', 2000),
    ('Macsa3465', 'Mohan', 40, 'M', 2000)
])
# update(table_name,data,where) 更新数据
dbo.update('employee',{'AGE':40,'SEX':"F"},{'LAST_NAME':'Wong','FIRST_NAME':'Macsa3468'})
# find(table_name,where) 单条查询
dbo.find('employee',{'LAST_NAME':'Wong','FIRST_NAME':'Macsa3468'})
# select(table_name,where) 多条查询
dbo.select('employee',{'LAST_NAME':'Wong','FIRST_NAME':'Macsa3468'})
# delete(table_name,where)
dbo.delete('employee',{'LAST_NAME':'Wong','FIRST_NAME':'Macsa3468'})

操作类下载地址:RocDb下载

注:转载请注明出处为http://www.www.xtaike.com/article/50.html。

沙豆网 站长

追求卓越,奋斗不息!

167
文章
8815
点赞

更多文章