From 34fcf5c9a4ced4d71771e23f6e0d6d551f13d0ea Mon Sep 17 00:00:00 2001 From: asos-gordon Date: Wed, 27 Feb 2019 20:43:00 +0000 Subject: [PATCH 1/2] DOC: Fix docstring for read_sql_table --- pandas/io/sql.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pandas/io/sql.py b/pandas/io/sql.py index aaface5415384..e52dd89df2478 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -182,26 +182,28 @@ def execute(sql, con, cur=None, params=None): def read_sql_table(table_name, con, schema=None, index_col=None, coerce_float=True, parse_dates=None, columns=None, chunksize=None): - """Read SQL database table into a DataFrame. + """ + Read SQL database table into a DataFrame. Given a table name and a SQLAlchemy connectable, returns a DataFrame. This function does not support DBAPI connections. Parameters ---------- - table_name : string + table_name : str Name of SQL table in database. - con : SQLAlchemy connectable (or database string URI) + con : SQLAlchemy connectable or database URI str SQLite DBAPI connection mode not supported. - schema : string, default None + schema : str, default None Name of SQL schema in database to query (if database flavor supports this). Uses default schema if None (default). - index_col : string or list of strings, optional, default: None + index_col : str or list of str, optional, default: None Column(s) to set as index(MultiIndex). - coerce_float : boolean, default True + coerce_float : bool, default True Attempts to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point. Can result in loss of Precision. - parse_dates : list or dict, default: None + parse_dates : list or dict, default None + The behavior is as follows: - List of column names to parse as dates. - Dict of ``{column_name: format string}`` where format string is strftime compatible in case of parsing string times or is one of @@ -210,8 +212,8 @@ def read_sql_table(table_name, con, schema=None, index_col=None, to the keyword arguments of :func:`pandas.to_datetime` Especially useful with databases without native Datetime support, such as SQLite. - columns : list, default: None - List of column names to select from SQL table + columns : list, default None + List of column names to select from SQL table. chunksize : int, default None If specified, returns an iterator where `chunksize` is the number of rows to include in each chunk. @@ -219,15 +221,21 @@ def read_sql_table(table_name, con, schema=None, index_col=None, Returns ------- DataFrame + A SQL table is returned as two-dimensional data structure with labeled + axes. See Also -------- read_sql_query : Read SQL query into a DataFrame. - read_sql + read_sql : Read SQL query or database table into a DataFrame. Notes ----- Any datetime values with time zone information will be converted to UTC. + + Examples + -------- + >>> pd.read_sql_table('table_name', 'postgres:///db_name') # doctest:+SKIP """ con = _engine_builder(con) From f114512598128433ce0ba278dde95467fde02f39 Mon Sep 17 00:00:00 2001 From: asos-gordon Date: Thu, 28 Feb 2019 16:41:15 +0000 Subject: [PATCH 2/2] Leave the arguement as just str and move the description (database URI) below --- pandas/io/sql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/sql.py b/pandas/io/sql.py index e52dd89df2478..02fba52eac7f7 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -192,7 +192,8 @@ def read_sql_table(table_name, con, schema=None, index_col=None, ---------- table_name : str Name of SQL table in database. - con : SQLAlchemy connectable or database URI str + con : SQLAlchemy connectable or str + A database URI could be provided as as str. SQLite DBAPI connection mode not supported. schema : str, default None Name of SQL schema in database to query (if database flavor