#显示MYSQL数据表有多少条记录 import pymysql pymysql.install_as_MySQLdb() """ www.jjddlc.com""" """作者:Pgabc""" def db_count(db_wm,db_nm): # 显示有多少条记录 db = pymysql.connect(host='127.0.0.1', user='root', passwd='XXXXXXXXX', db=db_wm, charset='utf8') cursor = db.cursor() query = " select count(*) from {}".format(db_nm) cursor.execute(query) db.commit() count_wm = cursor.fetchall() # print(db_nm,'数据库共有',count_wm[0][0],'数据') if __name__=='__main__': db_wm = 'stock' #mysql数据库名 db_nm = 'stock_daily' #mysql数据表名 db_count(db_wm,db_nm)
python 显示mysql数据表有多少条记录
最新推荐文章于 2024-07-08 21:15:10 发布