Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. ort psycopg2
  2.  
  3. conn = psycopg2.connect("host=localhost dbname=postgres user=postgres password=postgres")
  4. cur = conn.cursor()
  5.  
  6.  
  7. def main():
  8. login()
  9.  
  10.  
  11. def login():
  12. print("***********************************")
  13. print("* ALUGUER DE BICICLETAS *")
  14. print("* by Amazing Lda *")
  15. print("***********************************")
  16. print("[1] Fazer Login")
  17. print("[2] Criar Conta")
  18. print("[3] Menu de Administrador")
  19. print("[0] Sair")
  20. print("Opção: ")
  21. option = "1"
  22.  
  23. while option != "0":
  24. option = input()
  25. if option == "1":
  26. print("E-mai: ")
  27. user = input()
  28. print("Password: ")
  29. password = input()
  30.  
  31. # Condição de que se o utilizador existe e a passe funciona pode ir para a funçao menu
  32.  
  33. cur.execute("SELECT count (*) from cliente where mail =%s and password=%s", (user, password))
  34. if cur.fetchone()[0] == 1:
  35. menuClient()
  36. else:
  37. print("USER NAO ENCONTRADO")
  38. login()
  39.  
  40.  
  41. elif option == "2":
  42. print("Digite o e-mail que pretende registar:")
  43. NewUser = input()
  44. print("Digite o seu nome:")
  45. name = input()
  46. print("Digite a password pretendida:")
  47. NewPass = input()
  48. # inserir o novo user e a pass e mandar para a funçao menu
  49. # como meter o Auto increment???
  50. # Ta a dar erro nao sei porque
  51. cur.execute("INSERT into cliente values (DEFAULT,%s, %s, %s, 10);", (name, NewUser, NewPass))
  52.  
  53. elif option == "3": # fazer menu administrador
  54. print("oli")
  55. elif option == "0":
  56. print("PROGRAMA ENCERRADO")
  57.  
  58.  
  59. def menuClient():
  60. option = "1"
  61. print(" M E N U C L I E N T E")
  62. print("")
  63. print(" Bem Vindo! ")
  64. print("")
  65. print("[1]Ver Bicicletas") # Aqui dentro precisa de opçao para ver detalhes
  66. print("[2]Alugar Bicicletas")
  67. print("[3]Devolver Bicicleta")
  68. print("[4]Historico de Alugueres") # aqui meter também quanto gastou em cada tipo de bicicleta
  69. print("[5]Mensagens") # distinguir lidas de nao lidas
  70. print("[6]Consultar Bicicletas")
  71. print("[0]Sair")
  72. print("Opção: ")
  73.  
  74. while option != "0":
  75.  
  76. option = input()
  77. if option == "1":
  78.  
  79. cur.execute("SELECT * from bicicleta")
  80. # meter a printar em condiçoes
  81. for linha in cur.fetchall():
  82. print(linha)
  83. a = input()
  84. if a == "0":
  85. menuClient()
  86.  
  87. elif option == "2":
  88. print("2")
  89. elif option == "3":
  90. print("3")
  91.  
  92. elif option == "4":
  93. print("4")
  94.  
  95.  
  96. elif option == "5":
  97. print("5")
  98.  
  99.  
  100. elif option == "6":
  101. print("6")
  102. elif option == "0":
  103. login()
  104.  
  105.  
  106. # Fazer Menu de Admin aqui
  107. # def menuAdmin():
  108.  
  109.  
  110. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement