Python implements mysql Single quotes string filtering method, pythonmysql
This article describes how to filter single quotes of mysql using python. We will share this with you for your reference. The details are as follows:
This function can be used to process MySQLdb. escape_string (content ).
Class Guide: def _ init _ (self): self. time_zone = 7*3600 # set the time zone self. now_time = int (time. time () + self. time_zone # obtain the current time # local self. gamedb_model = mysql_conn.MySQLHelper (config. game_db ['host'], config. game_db ['user'], config. game_db ['Password'], config. game_db ['db _ name'], config. game_db ['Port']) # remote self. remote_model = mysql_conn.MySQLHelper (config. remote_db ['host'], config. remote_db ['user'], config. remote_db ['Password'], config. remote_db ['db _ name'], config. remote_db ['Port']) # game center self. commdb_model = mysql_conn.MySQLHelper (config. comm_db ['host'], config. comm_db ['user'], config. comm_db ['Password'], config. comm_db ['db _ name'], config. comm_db ['Port']) def index (self): # Get the user for line in open ("2014.3.20_global_ips.txt") not logged in the next day: list = line. split ('|') l = len (list) if l = 3: info = ''else: info = MySQLdb. escape_string (list [3]) self. commdb_model.insert ('IP _ region', {'start _ ip': list [0], 'end _ ip': list [1], 'area ': list [2], 'info': info}) if _ name _ = "_ main _": keep = Guide () keep. index ()
I hope this article will help you with python programming.