#显示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数据表有多少条记录的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复