Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- db = mysql.connector.connect(host="localhost",
- user="root",
- password="", database="db112300xx")
- cursor = db.cursor()
- while(True):
- npm=input("Input NPM: ")
- val=(npm,)
- sql = "SELECT * FROM tblmahasiswa WHERE npm_mhs=%s"
- cursor.execute(sql,val)
- results = cursor.fetchall()
- if(cursor.rowcount==0):
- print("Record tidak ada/ditemukan...")
- else:
- for data in results:
- print(f"Nomor Record : {data[0]}\n"
- f"NPM Mahasiswa : {data[1]}\n"
- f"Nama Mahasiswa : {data[2]}\n"
- f"Jenis Kelamin (P/L) : {data[3]}\n"
- f"Program Studi (SI/IF): {data[4]}\n")
- ulang=input("Ulangi pencarian data? (y/t) ").lower()
- if(ulang!="y"):
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement