Speed Up Pandas .to_sql to Insert Data - 100x Faster ( Using SQLalchemy)

You need to make following change in pandas package.

Steps:

  1. Go to Pandas Packages.
  2. Go to io folder. Pandas > io
  3. Now Open sql.py file. Pandas > io > sql.py
  4. Look for the method _execute_insert

def _execute_insert(self, conn, keys, data_iter):
    data = [{k: v for k, v in zip(keys, row)} for row in data_iter]
    # conn.execute(self.insert_statement(), data)   
    conn.execute(self.insert_statement().values(data)

Replace your function with above function.

Now, check your speed.

Comments

Popular posts from this blog

Real Time Twitter Sentiment Analysis Using Spark ,Twitter Streaming API and write to Elastic Serach

Visualize Real Time Twitter Sentiment Analysis Elastic Search and Kibana