Skip to content

Commit 0f5c1d6

Browse files
SQL: add release notes for refactor (GH6292)
1 parent 76f6cf0 commit 0f5c1d6

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

doc/source/release.rst

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ New features
6666
in pandas the actual range of dates that you can use is 1678 AD to 2262 AD. (:issue:`4041`)
6767
- Added error bar support to the ``.plot`` method of ``DataFrame`` and ``Series`` (:issue:`3796`, :issue:`6834`)
6868
- Implemented ``Panel.pct_change`` (:issue:`6904`)
69+
- The SQL reading and writing functions now support more database flavors
70+
through SQLAlchemy (:issue:`2717`, :issue:`4163`, :issue:`5950`, :issue:`6292`).
6971

7072
API Changes
7173
~~~~~~~~~~~
@@ -257,6 +259,8 @@ Deprecations
257259
- The support for the 'mysql' flavor when using DBAPI connection objects has been deprecated.
258260
MySQL will be further supported with SQLAlchemy engines (:issue:`6900`).
259261

262+
- The following ``io.sql`` functions have been deprecated: ``tquery``, ``uquery``, ``read_frame``, ``frame_query``, ``write_frame``.
263+
260264
- The `percentile_width` keyword argument in :meth:`~DataFrame.describe` has been deprecated.
261265
Use the `percentiles` keyword instead, which takes a list of percentiles to display. The
262266
default output is unchanged.

doc/source/v0.14.0.txt

+67
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,71 @@ More consistent behaviour for some groupby methods:
340340
SQL
341341
~~~
342342

343+
The SQL reading and writing functions now support more database flavors
344+
through SQLAlchemy (:issue:`2717`, :issue:`4163`, :issue:`5950`, :issue:`6292`).
345+
All databases supported by SQLAlchemy can be used, such
346+
as PostgreSQL, MySQL, Oracle, Microsoft SQL server (see documentation of
347+
SQLAlchemy on `included dialects
348+
<http://sqlalchemy.readthedocs.org/en/latest/dialects/index.html>`_).
349+
350+
The functionality of providing DBAPI connection objects will only be supported
351+
for sqlite3 in the future. The ``'mysql'`` flavor is deprecated.
352+
353+
The new functions :func:`~pandas.read_sql_query` and :func:`~pandas.read_sql_table`
354+
are introduced. The function :func:`~pandas.read_sql` is kept as a convenience
355+
wrapper around the other two and will delegate to specific function depending on
356+
the provided input (database table name or sql query).
357+
358+
In practice, you have to provide a SQLAlchemy ``engine`` to the sql functions.
359+
To connect with SQLAlchemy you use the :func:`create_engine` function to create an engine
360+
object from database URI. You only need to create the engine once per database you are
361+
connecting to. For an in-memory sqlite database:
362+
363+
.. ipython:: python
364+
365+
from sqlalchemy import create_engine
366+
# Create your connection.
367+
engine = create_engine('sqlite:///:memory:')
368+
369+
This ``engine`` can then be used to write or read data to/from this database:
370+
371+
.. ipython:: python
372+
373+
df = pd.DataFrame({'A': [1,2,3], 'B': ['a', 'b', 'c']})
374+
df.to_sql('db_table', engine, index=False)
375+
376+
You can read data from a database by specifying the table name:
377+
378+
.. ipython:: python
379+
380+
pd.read_sql_table('db_table', engine)
381+
382+
or by specifying a sql query:
383+
384+
.. ipython:: python
385+
386+
pd.read_sql_query('SELECT * FROM db_table', engine)
387+
388+
Some other enhancements to the sql functions include:
389+
390+
- support for writing the index. This can be controlled with the ``index``
391+
keyword (default is True).
392+
- specify the column label to use when writing the index with ``index_label``.
393+
- specify string columns to parse as datetimes withh the ``parse_dates``
394+
keyword in :func:`~pandas.read_sql_query` and :func:`~pandas.read_sql_table`.
395+
396+
.. warning::
397+
398+
Some of the existing functions or function aliases have been deprecated
399+
and will be removed in future versions. This includes: ``tquery``, ``uquery``,
400+
``read_frame``, ``frame_query``, ``write_frame``.
401+
402+
.. warning::
403+
404+
The support for the 'mysql' flavor when using DBAPI connection objects has been deprecated.
405+
MySQL will be further supported with SQLAlchemy engines (:issue:`6900`).
406+
407+
343408
.. _whatsnew_0140.slicers:
344409

345410
MultiIndexing Using Slicers
@@ -573,6 +638,8 @@ Deprecations
573638
- The support for the 'mysql' flavor when using DBAPI connection objects has been deprecated.
574639
MySQL will be further supported with SQLAlchemy engines (:issue:`6900`).
575640

641+
- The following ``io.sql`` functions have been deprecated: ``tquery``, ``uquery``, ``read_frame``, ``frame_query``, ``write_frame``.
642+
576643
- The `percentile_width` keyword argument in :meth:`~DataFrame.describe` has been deprecated.
577644
Use the `percentiles` keyword instead, which takes a list of percentiles to display. The
578645
default output is unchanged.

0 commit comments

Comments
 (0)