import pymysql def select(sql): conn = pymysql.connect(host='localhost',user='root', passwd='123456', charset='utf8') cursor = conn.cursor() conn.select_db('goods') # -----------Begin---------- # 请在下面输入查询数据的语句,完成相应功能 command = sql cursor.execute(command) # 请在下面输入获取数据的语句,完成相应功能 records = cursor.fetchall() # ------------End----------- # 关闭数据库连接 cursor.close() conn.close() return records def delete(sql): conn = pymysql.connect(host='localhost',user='root', passwd='123456', charset='utf8') cursor = conn.cursor() conn.select_db('goods') # -----------Begin---------- # 请在下面输入查询数据的语句,完成相应功能 command = sql cursor.execute(command) # 请在下面输入获取数据的语句,完成相应功能 # ------------End----------- # 提交数据到数据库 conn.commit() # 关闭数据库连接 cursor.close() conn.close() def alter(sql): conn = pymysql.connect(host='localhost', user='root', passwd='123456', charset='utf8') cursor = conn.cursor() conn.select_db('goods') command=sql cursor.execute(command) # 提交数据到数据库 conn.commit() # 关闭数据库连接 cursor.close() conn.close()