# ------------------------------------------- select -----------------------------------------------------
print '-' * 60
print 'first record'
result = hero.selectFirst('heros')
print result
print '-' * 60
print 'last record'
result = hero.selectLast('heros')
print result
print '-' * 60
print 'more record'
results = hero.selectNRecord('heros', 3)
for item in results:
print item
print '-' * 60
print 'all record'
results = hero.selectAll('heros')
for item in results:
print item
# ------------------------------------------- update -----------------------------------------------------
hero.updateSingle('heros', ['Zeus', 1, 22000, 'The god.', 2])
values = []
values.append(['SunWukong', 1, 1300, 'The hero who in fairy tale.', 1])
values.append(['Zeus', 1, 50000, 'The king who in The Quartet myth.', 2])
values.append(['Prophet', 1, 20000, 'The hero who in fairy tale.3', 3])
hero.update('heros', values)
# ------------------------------------------- delete -----------------------------------------------------
hero.deleteByID('heros', 1)
hero.dropTable('heros')
hero.dropDB('hero')
if __name__ == '__main__':
main()
注:请不要不假思索地使用他们。如果你想实现某一个功能点,请最好将其他的功能点注释掉,这样才符合单元测试的规范。
源码下载:
------------------------------------------分割线------------------------------------------
具体下载目录在 /2015年资料/4月/21日/Python访问MySQL数据库并实现其增删改查功能/
------------------------------------------分割线------------------------------------------