交互式数据库系统(shelve)
来源:互联网 发布:js动态创建对象 编辑:程序博客网 时间:2024/06/06 13:12
一个交互式存储系统
import shelvedef store_person(db): """ Query user for data and store it in the shelf object """ pid = raw_input('Enter unique ID number: ') person = {} person['name'] = raw_input('Enter name: ') person['age'] = raw_input('Enter Age: ') person['iphone'] = raw_input('Enter phone number: ') db[pid] = persondef lookup_person(db): """ Query user for ID and desired field. and fetch the corresponding data from the shelf object """ pid = raw_input('Enter ID number: ') field = raw_input('What would u like to know?(name,age,phone)') filed = field.strip().lower() print field.capitalize()+':',db[pid][field]def print_help(): print 'The available commands are:' print 'store :Stores information about a person' print 'lookup :Looks up a person from ID number' print 'quit :Save changes and exit' print '? :Prints this message'def enter_command(): cmd = raw_input('Enter command(? for help): ') cmd = cmd.strip().lower() return cmddef main(): database = shelve.open('/var/www/Python/ClassTen/database.dat') try: while True: cmd = enter_command() if cmd == 'store': store_person(database) elif cmd == 'lookup': lookup_person(database) elif cmd == '?': print_help() elif cmd == 'quit': return finally: print 'There is some error...' database.close()if __name__ == '__main__':main()
阅读全文
0 0
- 交互式数据库系统(shelve)
- shelve
- shelve
- 交互式分析系统
- [Python]使用shelve方法建立网页书签数据库
- Python利用shelve模块设计简单数据库程序
- 交互式列表的系统字段
- 交互式
- shelve函数
- shelve模块
- shelve模块
- python shelve
- 人本界面:交互式系统设计
- 应用系统中交互式报表功能解析
- 应用系统中交互式报表功能解析
- 应用系统中交互式报表功能解析
- 交互式系统中采用的调度算法
- 论基于Web的交互式数据库查询技术
- mysql for update行级锁
- 禁止用户查询某个列
- 并查集详解 (转)
- 组合主键映射
- C语言可变参数在宏定义中的应用
- 交互式数据库系统(shelve)
- CSU 1726:你经历过绝望吗?两次! (BFS+优先队列)
- 使用 PyInstaller 把python程序 .py转为 .exe 可执行程序
- 2017暑假集训第一天
- 阻止form表单提交按钮的默认 action
- Spring(14)——PropertyOverrideConfigurer
- Spring 事务的隔离性,并说说每个隔离性的区别,Spring 使用注解方式进行事务管理
- 《C++ Primer Plus》之string类和标准模板库笔记
- 安装MariaDB