我想打印出数据库中的所有表,然后打印出每个表的行数。目前我可以打印所有表格
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database = "data1"
)
mycursor = mydb.cursor()
query = 'show tables'
#query2 = 'select count(*)'
mycursor.execute(query)
for x in mycursor:
print(x)
答案 0 :(得分:0)
您想查看INFORMATION_SCHEMA.TABLES
表,特别是TABLE_ROWS
列。查看文档:{{3}}