con = pymysql.connect(host='192.168.0.10', user='root', passwd='123456', db='living', port = 3306) # 连接
cur = con.cursor()sql_order = 'select * from p_table'
p_table_in = read_table(cur, sql_order)
sql_order = "select COLUMN_NAME from information_schema.COLUMNS where table_name = 'p_table' and table_schema = 'living' "
p_table_name=read_table(cur, sql_order)
con.commit()
cur.close()
con.close()

本文展示了一个使用 Python 的 pymysql 库连接 MySQL 数据库并从中读取数据的简单示例。示例包括了连接数据库、执行 SQL 查询以及关闭连接等基本步骤。
2771

被折叠的 条评论
为什么被折叠?



