Use python to batch import data to Redis, and use pythonredis to import data
1. Batch import data using pipeline
Class Redis_Handler (Handler): def connect (self): # print self. host, self. port, self. tableself. conn = Connection (self. host, self. port, self. table) def execute (self, action_name): filename = "/tmp/temp.txt" batch_size = 10000 with open (filename) as file: try: count = 0pipeline_redis = self. conn. client. pipeline () for lines in file :( key, value) = lines. split (',') count = count + 1if len (key)> 0: pipeline_redis.rpush (key, value. strip () if not count % batch_size: pipeline_redis.execute () count = 0 # send the last batchpipeline_redis.execute () failed t Exception: print 'redis add error'
Batch transaction submission failed due to the problem of batch mysql Data insertion in python
Conn. commit () # You have missing the brackets
Python batch processing excel Data
Is there a problem with new_row1? Write it to a new sheet. You can easily modify the row number while reading the table.