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="db11230070")
- cursor = db.cursor()
- sql = "select * from tblmahasiswa order by id"
- cursor.execute(sql)
- results = cursor.fetchall()
- if(cursor.rowcount==0):
- print("Record tidak ada/ditemukan...")
- else:
- idx = 1
- 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")
- if(idx==5):
- idx = 0
- ulang = input('Tampilkan record selanjutnya ? (y/t) ').lower()
- if(ulang!='y'):
- break
- idx+=1
- print(f"Jumlah Record : {cursor.rowcount}\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement