Skip to content

Commit d151b90

Browse files
SQL: keep backwards compatibility for write_frame index handling
1 parent ca44b2e commit d151b90

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

pandas/io/sql.py

+37-3
Original file line numberDiff line numberDiff line change
@@ -989,13 +989,47 @@ def read_frame(*args, **kwargs):
989989
return read_sql(*args, **kwargs)
990990

991991

992-
def write_frame(*args, **kwargs):
992+
def write_frame(frame, name, con, flavor='sqlite', if_exists='fail', **kwargs):
993993
"""DEPRECIATED - use to_sql
994+
995+
Write records stored in a DataFrame to a SQL database.
996+
997+
Parameters
998+
----------
999+
frame : DataFrame
1000+
name : string
1001+
con : DBAPI2 connection
1002+
flavor : {'sqlite', 'mysql'}, default 'sqlite'
1003+
The flavor of SQL to use.
1004+
if_exists : {'fail', 'replace', 'append'}, default 'fail'
1005+
- fail: If table exists, do nothing.
1006+
- replace: If table exists, drop it, recreate it, and insert data.
1007+
- append: If table exists, insert data. Create if does not exist.
1008+
index : boolean, default False
1009+
Write DataFrame index as a column
1010+
1011+
Notes
1012+
-----
1013+
This function is deprecated in favor of ``to_sql``. There are however
1014+
two differences:
1015+
1016+
- With ``to_sql`` the index is written to the sql database by default. To
1017+
keep the behaviour this function you need to specify ``index=False``.
1018+
- The new ``to_sql`` function supports sqlalchemy engines to work with
1019+
different sql flavors.
1020+
1021+
See also
1022+
--------
1023+
pandas.DataFrame.to_sql
1024+
9941025
"""
9951026
warnings.warn("write_frame is depreciated, use to_sql", DeprecationWarning)
996-
return to_sql(*args, **kwargs)
1027+
1028+
# for backwards compatibility, set index=False when not specified
1029+
index = kwargs.pop('index', False)
1030+
return to_sql(frame, name, con, flavor=flavor, if_exists=if_exists,
1031+
index=index, **kwargs)
9971032

9981033

9991034
# Append wrapped function docstrings
10001035
read_frame.__doc__ += read_sql.__doc__
1001-
write_frame.__doc__ += to_sql.__doc__

0 commit comments

Comments
 (0)