dbutil.closeDB(); break; elif menu == 'c': oneUser = input('Input User Data: ').split(' '); dbutil.insertUser(oneUser); elif menu == 'r': print('Select Users Info...'); allUsers = dbutil.selectUser(); for user in allUsers: print('%s %s %s %s %s %d' % (user[0],user[1],user[2],user[3],user[4],user[5])); elif menu == 'ro': userID = input('Input User ID: '); user = dbutil.selectOneUser(userID); print('%s %s %s %s %s %d' % (user[0],user[1],user[2],user[3],user[4],user[5])); elif menu == 'u': oneUser = input('Input User Data: ').split(' '); dbutil.updateUser(oneUser); elif menu == 'd': userID = input('Input User ID: '); dbutil.deleteUser(userID); except: print('Error...'); except : print('Error...') finally: dbutil.closeDB();
if menu == 'q': dbutil.closeDB() break if menu == 'c': smenu = input('Input user data : ') userdata = smenu.split(' ') userdata[5] = int(userdata[5]) dbutil.insertUser(userdata) if menu == 'r': allusers = dbutil.selectUser() for user in allusers: print('%s %s %s %s %s %d' % (user[0], user[1], user[2], user[3], user[4], user[5])) if menu == 'ro': smenu = input('Input user ID : ') user = dbutil.selectOneUser(smenu) for i in user: print(i, end=' ') print() if menu == 'u': smenu = input('Input user data : ') userdata = smenu.split(' ') userdata[5] = int(userdata[5]) dbutil.updateUser(userdata) if menu == 'd': smenu = input('Input user ID : ') dbutil.deleteUser(smenu) except: print('Error') finally: dbutil.closeDB()
# 2. Table을 만든다. dbutil.makeTable(); # 3. 사용자 정보를 입력한다. user = ['id14','pwd14','홍말숙','01077776666','경기',20]; # dbutil.insertUser(user); # 3-1. 한명 조회 user = dbutil.selectOneUser('id01'); print(user); print(); # 3-2. 수정 user = ['id01', '11111111', '이말숙', '01077776666', '경기', 20]; dbutil.updateUser(user); # 3-3. 삭제 dbutil.deleteUser('id02'); # 4. 사용자 정보를 조회한다. allusers = dbutil.selectUser(); for user in allusers: print(user); except sqlite3.IntegrityError: print('Duplicated ID Except...') finally: # 5. SQLite를 Close 한다. dbutil.closeDB(); print('end')