- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19.2k
Closed
Labels
Description
Is your feature request related to a problem?
pd.to_sql should definitely have a progress bar while dumping *df.to_sql *just like
pandas.to_gbq
Describe the solution you'd like
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_gbq.html
pd.to_sql should have progress_bar=True as a boolean parameter in case the user is sending the data in chunks or if the user wants to see the progress.
Describe alternatives you've considered
https://stackoverflow.com/questions/39494056/progress-bar-for-pandas-dataframe-to-sql
import sqlite3
import pandas as pd
from tqdm import tqdm
DB_FILENAME='/tmp/test.sqlite'
def chunker(seq, size):
    # from http://stackoverflow.com/a/434328
    return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
def insert_with_progress(df, dbfile):
    con = sqlite3.connect(dbfile)
    chunksize = int(len(df) / 10) # 10%
    with tqdm(total=len(df)) as pbar:
        for i, cdf in enumerate(chunker(df, chunksize)):
            replace = "replace" if i == 0 else "append"
            cdf.to_sql(con=con, name="MLS", if_exists=replace, index=False)
            pbar.update(chunksize)
df = pd.DataFrame({'a': range(0,100000)})
insert_with_progress(df, DB_FILENAME)vlasvlasvlas, noob-4-life, staplezz and olbask