mysql
1 import pymysql 2 3 4 def main(): 5 conn = pymysql.connect(host="localhost", port=3306, user="", password="", 6 database="all_ip", charset="utf8") 7 8 cc = conn.cursor() 9 10 sql = """select * from ip""" 11 12 cc.execute(sql) 13 14 # 前面执行的增删改可以回滚操作 15 # conn.rollback() 16 17 # 一旦提交了操作,那么都会对上面的增删改生效 18 conn.commit() 19 20 # 关闭cursor对象 21 cc.close() 22 conn.close() 23 24 25 if __name__ == '__main__': 26 main()