Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Importing modules
- import os
- import mysql.connector as mc
- import platform
- # MySQL Connection
- cnx = mc.connect(host="localhost", user="alen", password="alen")
- cur = cnx.cursor()
- # Dumping a default database
- cur.execute("CREATE DATABASE IF NOT EXISTS CRIMERECORD")
- cur.execute("USE CRIMERECORD")
- # CREATING TABLES FOR THE DATABASE
- cur.execute("CREATE TABLE IF NOT EXISTS USERS(SNO INT PRIMARY KEY, UID VARCHAR(20), UPASS LONGTEXT)")
- cur.execute("CREATE TABLE IF NOT EXISTS CRIMINALS(SNO INT PRIMARY KEY, CNAME VARCHAR(30), C_COMMITTED VARCHAR(255), CRIME_DESC LONGTEXT)")
- # OS Platform check
- def os_check():
- c = platform.system()
- if c == "Windows":
- return 1
- elif c == "Linux" or c == "Darwin":
- return 2
- #Login page function call
- def usercheck(a,b):
- print("Checking whether your credentials are valid")
- cur.execute("SELECT * FROM USERS")
- e = cur.fetchall()
- for k in e:
- if k[1] == a and k[2] == b:
- print("Your credentials are valid and you can continue")
- return 1
- else:
- print("Invalid credentials")
- return 0
- # Login Page
- d = os_check()
- if d == 1:
- os.system("cls")
- elif d == 2:
- os.system("clear")
- print("{:<20}".format("User Login"))
- a = input("Enter your username: ")
- b = input("Enter your password: ")
- f = usercheck(a,b)
- if f == 1:
- print("Moving to next page")
- if d == 1:
- os.system("cls")
- elif d == 2:
- os.system("clear")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement