Repository: pandas-dev/pandas

Issue:
Unclear what chunksize represents in to_sql() docs
From http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_sql.html

> **chunksize** _: int, default None_
> If not None, then rows will be written in batches of this size at a time. If None, all rows will be written at once.

"this size"? Sounds like it could be the max size in bytes. How about "this number of rows"?

I think that's right given read_sql() says:
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sql.html

> **chunksize** _: int, default None_
> If specified, return an iterator where chunksize is the number of rows to include in each chunk.

If that's not right please let me know. Thanks!



Discussion:
That sounds good. Do you want to do a PR to change this?

Source code is here: https://github.com/pydata/pandas/blob/master/pandas/io/sql.py#L516 and here: https://github.com/pydata/pandas/blob/master/pandas/core/generic.py#L990

Thanks! I'll put in the PR tomorrow

On Thursday, October 22, 2015, Joris Van den Bossche <
notifications@github.com> wrote:

> That sounds good. Do you want to do a PR to change this?
> 
> Source code is here:
> https://github.com/pydata/pandas/blob/master/pandas/io/sql.py#L516 and
> here:
> https://github.com/pydata/pandas/blob/master/pandas/core/generic.py#L990
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/pydata/pandas/issues/11415#issuecomment-150379782.


Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -2594,13 +2594,14 @@ def to_sql(
             `index` is True, then the index names are used.
             A sequence should be given if the DataFrame uses MultiIndex.
         chunksize : int, optional
-            Rows will be written in batches of this size at a time. By default,
-            all rows will be written at once.
-        dtype : dict, optional
-            Specifying the datatype for columns. The keys should be the column
-            names and the values should be the SQLAlchemy types or strings for
-            the sqlite3 legacy mode.
-        method : {None, 'multi', callable}, default None
+            Specify the number of rows in each batch to be written at a time.
+            By default, all rows will be written at once.
+        dtype : dict or scalar, optional
+            Specifying the datatype for columns. If a dictionary is used, the
+            keys should be the column names and the values should be the
+            SQLAlchemy types or strings for the sqlite3 legacy mode. If a
+            scalar is provided, it will be applied to all columns.
+        method : {None, 'multi', callable}, optional
             Controls the SQL insertion clause used:
 
             * None : Uses standard SQL ``INSERT`` clause (one per row).
diff --git a/pandas/io/sql.py b/pandas/io/sql.py
--- a/pandas/io/sql.py
+++ b/pandas/io/sql.py
@@ -456,14 +456,14 @@ def to_sql(
     Parameters
     ----------
     frame : DataFrame, Series
-    name : string
+    name : str
         Name of SQL table.
     con : SQLAlchemy connectable(engine/connection) or database string URI
         or sqlite3 DBAPI2 connection
         Using SQLAlchemy makes it possible to use any DB supported by that
         library.
         If a DBAPI2 object, only sqlite3 is supported.
-    schema : string, default None
+    schema : str, optional
         Name of SQL schema in database to write to (if database flavor
         supports this). If None, use default schema (default).
     if_exists : {'fail', 'replace', 'append'}, default 'fail'
@@ -472,18 +472,19 @@ def to_sql(
         - append: If table exists, insert data. Create if does not exist.
     index : boolean, default True
         Write DataFrame index as a column.
-    index_label : string or sequence, default None
+    index_label : str or sequence, optional
         Column label for index column(s). If None is given (default) and
         `index` is True, then the index names are used.
         A sequence should be given if the DataFrame uses MultiIndex.
-    chunksize : int, default None
-        If not None, then rows will be written in batches of this size at a
-        time.  If None, all rows will be written at once.
-    dtype : single SQLtype or dict of column name to SQL type, default None
-        Optional specifying the datatype for columns. The SQL type should
-        be a SQLAlchemy type, or a string for sqlite3 fallback connection.
-        If all columns are of the same type, one single value can be used.
-    method : {None, 'multi', callable}, default None
+    chunksize : int, optional
+        Specify the number of rows in each batch to be written at a time.
+        By default, all rows will be written at once.
+    dtype : dict or scalar, optional
+        Specifying the datatype for columns. If a dictionary is used, the
+        keys should be the column names and the values should be the
+        SQLAlchemy types or strings for the sqlite3 fallback mode. If a
+        scalar is provided, it will be applied to all columns.
+    method : {None, 'multi', callable}, optional
         Controls the SQL insertion clause used:
 
         - None : Uses standard SQL ``INSERT`` clause (one per row).


Test patch: