0

Why is this not printing anything

import mysql.connector Dbase = mysql.connector.connect(host="localhost", user="jeremy", password="jcvcruz123", database="userInfo") my_cursor = Dbase.cursor() my_cursor.execute("select * from info") for i in my_cursor: print(i) #it only says "Process finished with exit code 0"

6th Jun 2020, 9:40 PM
Jeremy Cruz
Jeremy Cruz - avatar
5 Answers
+ 4
Try; print(Dbase) Also try; my_cursor.execute("SHOW DATABASES") for db in my_cursor: print(db) If you don't see your connection or your database then you have found your issue. If they do print then you need to add to a row to your database and commit() it.
6th Jun 2020, 10:52 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Before your for loop and after your query, try; result = my_cursor.fetchall() Then loop over result instead of my_cursor. for i in result: https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_mysql_select.asp
6th Jun 2020, 9:50 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Try printing my_cursor.rowcount and see how many entries are there. Maybe it's empty?
6th Jun 2020, 10:04 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
nope, still prints nothing.
6th Jun 2020, 9:53 PM
Jeremy Cruz
Jeremy Cruz - avatar
0
It says zero, but I made one already. This has me confused.
6th Jun 2020, 10:12 PM
Jeremy Cruz
Jeremy Cruz - avatar