Home > OS >  Store number of rows in mysql data in variable
Store number of rows in mysql data in variable

Time:03-13

SELECT COUNT( *) as "Number of Rows"
FROM orders;

i want to add "Number of rows" into a python variable but idk how.

CodePudding user response:

stored numbers of rows in python variables

db= MySQLdb.connect("HOSTNAME", "USER_NAME", "PWD", "DB_NAME");
cursor= db.cursor();
number_of_rows = cursor.execute("SELECT COUNT (*) FROM TBL");
print(number_of_rows);

  • Related