Advertisement
ALENTL

Untitled

Oct 5th, 2022
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. # Importing modules
  2. import os
  3. import mysql.connector as mc
  4. import platform
  5.  
  6. # MySQL Connection
  7. cnx = mc.connect(host="localhost", user="alen", password="alen")
  8. cur = cnx.cursor()
  9.  
  10. # Dumping a default database
  11. cur.execute("CREATE DATABASE IF NOT EXISTS CRIMERECORD")
  12. cur.execute("USE CRIMERECORD")
  13.  
  14. # CREATING TABLES FOR THE DATABASE
  15. cur.execute("CREATE TABLE IF NOT EXISTS USERS(SNO INT PRIMARY KEY, UID VARCHAR(20), UPASS LONGTEXT)")
  16. cur.execute("CREATE TABLE IF NOT EXISTS CRIMINALS(SNO INT PRIMARY KEY, CNAME VARCHAR(30), C_COMMITTED VARCHAR(255), CRIME_DESC LONGTEXT)")
  17.  
  18. # OS Platform check
  19. def os_check():
  20. c = platform.system()
  21.  
  22. if c == "Windows":
  23. return 1
  24.  
  25. elif c == "Linux" or c == "Darwin":
  26. return 2
  27.  
  28. #Login page function call
  29. def usercheck(a,b):
  30. print("Checking whether your credentials are valid")
  31. cur.execute("SELECT * FROM USERS")
  32. e = cur.fetchall()
  33. for k in e:
  34. if k[1] == a and k[2] == b:
  35. print("Your credentials are valid and you can continue")
  36. return 1
  37. else:
  38. print("Invalid credentials")
  39. return 0
  40.  
  41. # Login Page
  42. d = os_check()
  43.  
  44. if d == 1:
  45. os.system("cls")
  46.  
  47. elif d == 2:
  48. os.system("clear")
  49.  
  50. print("{:<20}".format("User Login"))
  51. a = input("Enter your username: ")
  52. b = input("Enter your password: ")
  53. f = usercheck(a,b)
  54.  
  55. if f == 1:
  56. print("Moving to next page")
  57. if d == 1:
  58. os.system("cls")
  59.  
  60. elif d == 2:
  61. os.system("clear")
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement