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"
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.
+ 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
+ 1
Try printing my_cursor.rowcount and see how many entries are there. Maybe it's empty?
0
nope, still prints nothing.
0
It says zero, but I made one already. This has me confused.