Skip to content

Commit 9c5eb32

Browse files
oguzhanogredenMarco Gorelli
authored and
Marco Gorelli
committed
DOC: Document existing functionality of pandas.DataFrame.to_sql() pandas-dev#11886 (pandas-dev#26795)
* DOC: add single dtype to NDFrame.to_sql
1 parent 23dea4b commit 9c5eb32

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Diff for: pandas/core/generic.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -2594,13 +2594,14 @@ def to_sql(
25942594
`index` is True, then the index names are used.
25952595
A sequence should be given if the DataFrame uses MultiIndex.
25962596
chunksize : int, optional
2597-
Rows will be written in batches of this size at a time. By default,
2598-
all rows will be written at once.
2599-
dtype : dict, optional
2600-
Specifying the datatype for columns. The keys should be the column
2601-
names and the values should be the SQLAlchemy types or strings for
2602-
the sqlite3 legacy mode.
2603-
method : {None, 'multi', callable}, default None
2597+
Specify the number of rows in each batch to be written at a time.
2598+
By default, all rows will be written at once.
2599+
dtype : dict or scalar, optional
2600+
Specifying the datatype for columns. If a dictionary is used, the
2601+
keys should be the column names and the values should be the
2602+
SQLAlchemy types or strings for the sqlite3 legacy mode. If a
2603+
scalar is provided, it will be applied to all columns.
2604+
method : {None, 'multi', callable}, optional
26042605
Controls the SQL insertion clause used:
26052606
26062607
* None : Uses standard SQL ``INSERT`` clause (one per row).

Diff for: pandas/io/sql.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,14 @@ def to_sql(
456456
Parameters
457457
----------
458458
frame : DataFrame, Series
459-
name : string
459+
name : str
460460
Name of SQL table.
461461
con : SQLAlchemy connectable(engine/connection) or database string URI
462462
or sqlite3 DBAPI2 connection
463463
Using SQLAlchemy makes it possible to use any DB supported by that
464464
library.
465465
If a DBAPI2 object, only sqlite3 is supported.
466-
schema : string, default None
466+
schema : str, optional
467467
Name of SQL schema in database to write to (if database flavor
468468
supports this). If None, use default schema (default).
469469
if_exists : {'fail', 'replace', 'append'}, default 'fail'
@@ -472,18 +472,19 @@ def to_sql(
472472
- append: If table exists, insert data. Create if does not exist.
473473
index : boolean, default True
474474
Write DataFrame index as a column.
475-
index_label : string or sequence, default None
475+
index_label : str or sequence, optional
476476
Column label for index column(s). If None is given (default) and
477477
`index` is True, then the index names are used.
478478
A sequence should be given if the DataFrame uses MultiIndex.
479-
chunksize : int, default None
480-
If not None, then rows will be written in batches of this size at a
481-
time. If None, all rows will be written at once.
482-
dtype : single SQLtype or dict of column name to SQL type, default None
483-
Optional specifying the datatype for columns. The SQL type should
484-
be a SQLAlchemy type, or a string for sqlite3 fallback connection.
485-
If all columns are of the same type, one single value can be used.
486-
method : {None, 'multi', callable}, default None
479+
chunksize : int, optional
480+
Specify the number of rows in each batch to be written at a time.
481+
By default, all rows will be written at once.
482+
dtype : dict or scalar, optional
483+
Specifying the datatype for columns. If a dictionary is used, the
484+
keys should be the column names and the values should be the
485+
SQLAlchemy types or strings for the sqlite3 fallback mode. If a
486+
scalar is provided, it will be applied to all columns.
487+
method : {None, 'multi', callable}, optional
487488
Controls the SQL insertion clause used:
488489
489490
- None : Uses standard SQL ``INSERT`` clause (one per row).

0 commit comments

Comments
 (0)