Speed Up Pandas .to_sql to Insert Data - 100x Faster ( Using SQLalchemy)
You need to make following change in pandas package.
Steps:
Replace your function with above function.
Now, check your speed.
Steps:
- Go to Pandas Packages.
- Go to io folder. Pandas > io
- Now Open sql.py file. Pandas > io > sql.py
- 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
Post a Comment