示例#1
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(5)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(Partner).filter(Partner.partner_id == value).update(
             {Partner.partner_id: value2})
     elif num == 2:
         session.query(Partner).filter(
             Partner.partner_name == value).update(
                 {Partner.partner_name: value2})
     session.commit()
示例#2
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(1)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(Owner).filter(Owner.owner_id == value).update(
             {Owner.owner_id: value2})
     elif num == 2:
         session.query(Owner).filter(Owner.owner_name == value).update(
             {Owner.owner_name: value2})
     elif num == 3:
         session.query(Owner).filter(Owner.owner_surname == value).update(
             {Owner.owner_surname: value2})
     session.commit()
示例#3
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(7)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(Contract).filter(
             Contract.contract_id == value).update(
                 {Contract.contract_id: value2})
     elif num == 2:
         session.query(Contract).filter(Contract.fc_id == value).update(
             {Contract.fc_id: value2})
     elif num == 3:
         session.query(Contract).filter(
             Contract.partner_id == value).update(
                 {Contract.partner_id: value2})
     session.commit()
示例#4
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(4)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(HeadCoach).filter(
             HeadCoach.coach_id == value).update(
                 {HeadCoach.coach_id: value2})
     elif num == 2:
         session.query(HeadCoach).filter(
             HeadCoach.coach_name == value).update(
                 {HeadCoach.coach_name: value2})
     elif num == 3:
         session.query(HeadCoach).filter(
             HeadCoach.coach_surname == value).update(
                 {HeadCoach.coach_surname: value2})
示例#5
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(6)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(Assistant).filter(
             Assistant.assistant_id == value).update(
                 {Assistant.assistant_id: value2})
     elif num == 2:
         session.query(Assistant).filter(
             Assistant.assistant_name == value).update(
                 {Assistant.assistant_name: value2})
     elif num == 3:
         session.query(Assistant).filter(
             Assistant.assistant_surname == value).update(
                 {Assistant.assistant_surname: value2})
     elif num == 4:
         session.query(Assistant).filter(Assistant.head_id == value).update(
             {Assistant.head_id: value2})
     session.commit()
示例#6
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(2)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(FootballClub).filter(
             FootballClub.fc_id == value).update(
                 {FootballClub.fc_id: value2})
     elif num == 2:
         session.query(FootballClub).filter(
             FootballClub.fc_name == value).update(
                 {FootballClub.fc_name: value2})
     elif num == 3:
         session.query(FootballClub).filter(
             FootballClub.fc_city == value).update(
                 {FootballClub.fc_city: value2})
     elif num == 4:
         session.query(FootballClub).filter(
             FootballClub.owner_id == value).update(
                 {FootballClub.owner_id: value2})
     session.commit()
示例#7
0
文件: Model.py 项目: mal1k/db-lab3
 def Update():
     num = View.attribute_list(3)
     value = input('Attribute value to update = ')
     value2 = input('New attribute value = ')
     if num == 1:
         session.query(Player).filter(Player.player_id == value).update(
             {Player.player_id: value2})
     elif num == 2:
         session.query(Player).filter(Player.player_name == value).update(
             {Player.player_name: value2})
     elif num == 3:
         session.query(Player).filter(
             Player.player_surname == value).update(
                 {Player.player_surname: value2})
     elif num == 4:
         session.query(Player).filter(
             Player.player_birthDate == value).update(
                 {Player.player_birthDate: value2})
     elif num == 5:
         session.query(Player).filter(Player.fc_id == value).update(
             {Player.fc_id: value2})
     session.commit()
示例#8
0
 def update():
     connect = Connect.makeConnect()
     cursor = connect.cursor()
     restart = True
     while restart:
         View.list()
         table = Model.validTable()
         if table == 1:
             scname = "'" + input(
                 'Attribute to update(where) name = ') + "'"
             View.attribute_list(1)
             in_restart = True
             while in_restart:
                 num = input('Number of attribute =>')
                 value = "'" + input('New value of attribute = ') + "'"
                 if num == '1':
                     set = '"name"= {}'.format(value)
                     in_restart = False
                 elif num == '2':
                     set = '"city"= {}'.format(value)
                     in_restart = False
                 elif num == '3':
                     set = '"type"= {}'.format(value)
                     in_restart = False
                 elif num == '4':
                     set = '"ID"= {}'.format(value)
                     in_restart = False
                 else:
                     print('\nIncorrect input, try again.')
             update = 'update "school" set {} where "name"= {}'.format(
                 set, scname)
             restart = False
             pass
         elif table == 2:
             clname = "'" + input(
                 'Attribute to update(where) name = ') + "'"
             View.attribute_list(2)
             in_restart = True
             while in_restart:
                 num = input('Number of attribute =>')
                 value = "'" + input('New value of attribute = ') + "'"
                 if num == '1':
                     set = '"ID"= {}'.format(value)
                     in_restart = False
                 elif num == '2':
                     set = '"Name"= {}'.format(value)
                     in_restart = False
                 elif num == '3':
                     set = '"Classroom"= {}'.format(value)
                     in_restart = False
                 elif num == '4':
                     set = '"School"= {}'.format(value)
                     in_restart = False
                 else:
                     print('\nIncorrect input, try again.')
             update = 'update "classes" set {} where "name"= {}'.format(
                 set, clname)
             restart = False
             pass
         elif table == 3:
             diname = "'" + input(
                 'Attribute to update(where) Name = ') + "'"
             View.attribute_list(3)
             in_restart = True
             while in_restart:
                 num = input('Number of attribute =>')
                 value = "'" + input('New value of attribute = ') + "'"
                 if num == '1':
                     set = '"ID"= {}'.format(value)
                     in_restart = False
                 elif num == '2':
                     set = '"Name"= {}'.format(value)
                     in_restart = False
                 elif num == '3':
                     set = '"Number of tests"= {}'.format(value)
                     in_restart = False
                 elif num == '4':
                     set = '"Lessons per week"= {}'.format(value)
                     in_restart = False
                 elif num == '5':
                     set = '"Teachers"= {}'.format(value)
                     in_restart = False
                 else:
                     print('\nIncorrect input, try again.')
             update = 'update "discipline" set {} where "name"= {}'.format(
                 set, diname)
             restart = False
             pass
         elif table == 4:
             tename = input('Attribute to update(where) Full_name = ')
             View.attribute_list(4)
             in_restart = True
             while in_restart:
                 num = input('Number of attribute =>')
                 value = "'" + input('New value of attribute = ') + "'"
                 if num == '1':
                     set = '"ID"= {}'.format(value)
                     in_restart = False
                 elif num == '2':
                     set = '"Full_name"= {}'.format(value)
                     in_restart = False
                 elif num == '3':
                     set = '"Number"= {}'.format(value)
                     in_restart = False
                 elif num == '4':
                     set = '"School"= {}'.format(value)
                     in_restart = False
                 elif num == '5':
                     set = '"Classes"= {}'.format(value)
                     in_restart = False
                 else:
                     print('\nIncorrect input, try again.')
             update = 'update "teachers" set {} where "full_name"= {}'.format(
                 set, tename)
             restart = False
             pass
         elif table == 5:
             stname = input('Attribute to update(where) Full name = ')
             View.attribute_list(5)
             in_restart = True
             while in_restart:
                 num = input('Number of attribute =>')
                 value = "'" + input('New value of attribute = ') + "'"
                 if num == '1':
                     set = '"ID"= {}'.format(value)
                     in_restart = False
                 elif num == '2':
                     set = '"Full_name"= {}'.format(value)
                     in_restart = False
                 elif num == '3':
                     set = '"Phone_number"= {}'.format(value)
                     in_restart = False
                 elif num == '4':
                     set = '"Cities"= {}'.format(value)
                     in_restart = False
                 elif num == '5':
                     set = '"Classes"= {}'.format(value)
                     in_restart = False
                 else:
                     print('\nIncorrect input, try again.')
             update = 'update "students" set {} where "full_name"= {}'.format(
                 set, stname)
             restart = False
             pass
         elif table == 6:
             dtname = "'" + input('Attribute to update(where) ID = ') + "'"
             View.attribute_list(6)
             in_restart = True
             while in_restart:
                 num = input('Number of attribute =>')
                 value = "'" + input('New value of attribute = ') + "'"
                 if num == '1':
                     set = '"ID"= {}'.format(value)
                     in_restart = False
                 elif num == '2':
                     set = '"Teachers"= {}'.format(value)
                     in_restart = False
                 elif num == '3':
                     set = '"Discipline"= {}'.format(value)
                     in_restart = False
                 else:
                     print('\nIncorrect input, try again.')
             update = 'update "teachers_discipline" set {} where "id"= {}'.format(
                 set, dtname)
             restart = False
             pass
         else:
             print('\nIncorrect input, try again.')
     print(tables[table])
     print("SQL query => ", update)
     cursor.execute(update)
     connect.commit()
     print('Data updeted successfully!')
     cursor.close()
     Connect.closeConnect(connect)
     pass