carlos0722

Untitled

Nov 30th, 2020 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. cursor=conexion.cursor()
  2.  
  3. def menu():
  4.     print("Bienvenido, al programa de telefonico, esto es un simulador de un telefono ")
  5.  
  6.     while True:
  7.         print("1: llamar a todos los registros")
  8.         print("2: llamar a un solo registro")
  9.         print("3: Borrar a uno de los registros")
  10.         print("4: actulizar los datos")
  11.         print("5: salir del juego")
  12.         op=input("Seleccionar una opcion: ")
  13.         if op == "1":
  14.             mostrar()
  15.         elif op == "2":
  16.             buscar()
  17.         elif op == "3":
  18.             borrar()
  19.         elif op == "4":
  20.             update()
  21.         else:
  22.             break
  23.            
  24. def mostrar():
  25.     cursor.execute(f'select *from amigos')
  26.     for row in cursor:
  27.         print(f'row={row}')
  28.     print()
  29.  
  30. def buscar():
  31.     sechtel=int(input("Ingrese el numero que quiere buscar: "))
  32.     query=cursor.execute(f"select * from amigos where telefono='{sechtel}' ")
  33.     for row in cursor:
  34.         print(f'row={row}')
  35.     conexion.commit()
  36.  
  37. ##
  38. def update():
  39.     uptel=int(input("Ingrese el numero que quiere actulizar: "))
  40.     uptel2=int(input("Ingrese el nuevo numero actulizar:"))
  41.     query=cursor.execute(f"update amigos set telefono='{uptel2}'  where telefono='{uptel}' ")
  42.     conexion.commit()
  43.     print("numero actulizado")
  44.  
  45.  
  46. def borrar():
  47.     btel=int(input("Ingrese el numero que quiera borra: "))
  48.     query=cursor.execute(f"delete from amigos where telefono='{btel}' ")
  49.     print("El numero esta borrado")
  50.     conexion.commit()
  51.  
  52. def salir():
  53.     print("Gracias, adios")
  54.  
  55. #principal
  56. menu()
  57. mostrar()
  58. buscar()
  59. borrar()
  60. update()
  61. salir()
  62.  
  63. if __name__ == "__main__":
  64.     menu()
  65.  
  66. conexion.close()
  67.  
  68.  
  69.  
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment