@@ -5047,6 +5047,17 @@ Example of a callable using PostgreSQL `COPY clause
5047
5047
from io import StringIO
5048
5048
5049
5049
def psql_insert_copy(table, conn, keys, data_iter):
5050
+ """
5051
+ Execute SQL statement inserting data
5052
+
5053
+ Parameters
5054
+ ----------
5055
+ table : pandas.io.sql.SQLTable
5056
+ conn : sqlalchemy.engine.Engine or sqlalchemy.engine.Connection
5057
+ keys : list of str
5058
+ Column names
5059
+ data_iter : Iterable that iterates the values to be inserted
5060
+ """
5050
5061
# gets a DBAPI connection that can provide a cursor
5051
5062
dbapi_conn = conn.connection
5052
5063
with dbapi_conn.cursor() as cur:
@@ -5080,6 +5091,18 @@ table name and optionally a subset of columns to read.
5080
5091
5081
5092
pd.read_sql_table(' data' , engine)
5082
5093
5094
+ .. note ::
5095
+
5096
+ Note that pandas infers column dtypes from query outputs, and not by looking
5097
+ up data types in the physical database schema. For example, assume ``userid ``
5098
+ is an integer column in a table. Then, intuitively, ``select userid ... `` will
5099
+ return integer-valued series, while ``select cast(userid as text) ... `` will
5100
+ return object-valued (str) series. Accordingly, if the query output is empty,
5101
+ then all resulting columns will be returned as object-valued (since they are
5102
+ most general). If you foresee that your query will sometimes generate an empty
5103
+ result, you may want to explicitly typecast afterwards to ensure dtype
5104
+ integrity.
5105
+
5083
5106
You can also specify the name of the column as the ``DataFrame `` index,
5084
5107
and specify a subset of columns to be read.
5085
5108
0 commit comments