@@ -3087,8 +3087,6 @@ The key functions are:
3087
3087
:func: `~pandas.io.sql.read_table `
3088
3088
3089
3089
3090
-
3091
-
3092
3090
In the following example, we use the `SQlite <http://www.sqlite.org/ >`__ SQL database
3093
3091
engine. You can use a temporary SQLite database where data are stored in
3094
3092
"memory".
@@ -3144,20 +3142,47 @@ the database using :func:`~pandas.io.sql.to_sql`.
3144
3142
3145
3143
sql.to_sql(data, ' data' , engine)
3146
3144
3147
- You can read from the database simply by
3148
- specifying a table name using the :func: `~pandas.io.sql.read_table ` function.
3145
+ You can read from the database simply by specifying a table
3146
+ name using the :func: `~pandas.io.sql.read_table ` function.
3147
+
3148
+ .. note ::
3149
+
3150
+ In order to use read_table, you MUST have the SQLAlchemy optional
3151
+ dependency installed.
3149
3152
3150
3153
.. ipython :: python
3151
3154
3152
3155
sql.read_table(' data' , engine)
3153
3156
3154
- You can also specify the name of the column as the DataFrame index:
3157
+ You can also specify the name of the column as the DataFrame index,
3158
+ and specify a subset of columns to be read.
3155
3159
3156
3160
.. ipython :: python
3157
3161
3158
3162
sql.read_table(' data' , engine, index_col = ' id' )
3163
+ sql.read_table(' data' , engine, columns = [' Col_1' , ' Col_2' ])
3164
+
3165
+ And you can explicitly force columns to be parsed as dates:
3166
+
3167
+ .. ipython :: python
3168
+
3169
+ sql.read_table(' data' , engine, parse_dates = [' Date' ])
3170
+
3171
+ If needed you can explicitly specifiy a format string, or a dict of arguments
3172
+ to pass to :func: `pandas.tseries.tools.to_datetime `.
3173
+
3174
+ .. code-block :: python
3175
+
3176
+ sql.read_table(' data' , engine, parse_dates = {' Date' : ' %Y-%m-%d ' })
3177
+ sql.read_table(' data' , engine, parse_dates = {' Date' : {' format' : ' %Y-%m-%d %H:%M:%S' }})
3178
+
3179
+ Querying
3180
+ ~~~~~~~~
3159
3181
3160
3182
You can also query using raw SQL in the :func: `~pandas.io.sql.read_sql ` function.
3183
+ In this case you must use valid SQL for your database.
3184
+ When using SQLAlchemy, you can also pass SQLAlchemy Expression language constructs,
3185
+ which are database-agnostic.
3161
3186
3162
3187
.. ipython :: python
3163
3188
@@ -3174,10 +3199,13 @@ There are a few other available functions:
3174
3199
3175
3200
:func: `~pandas.io.sql.has_table ` checks if a given table exists.
3176
3201
3202
+ <<<<<<< HEAD
3177
3203
:func: `~pandas.io.sql.tquery ` returns a list of tuples corresponding to each row.
3178
3204
3179
3205
:func: `~pandas.io.sql.uquery ` does the same thing as tquery, but instead of
3180
3206
returning results it returns the number of related rows.
3207
+ =======
3208
+ >>>>>>> ac6bf42... ENH #4163 Added more robust type coertion, datetime parsing, and parse date options. Updated optional dependancies
3181
3209
3182
3210
In addition, the class :class: `~pandas.io.sql.PandasSQLWithEngine ` can be
3183
3211
instantiated directly for more manual control over the SQL interaction.
0 commit comments