@@ -3160,7 +3160,8 @@ your database.
3160
3160
.. versionadded :: 0.14.0
3161
3161
3162
3162
If SQLAlchemy is not installed, a fallback is only provided for sqlite (and
3163
- for mysql for backwards compatibility, but this is deprecated).
3163
+ for mysql for backwards compatibility, but this is deprecated and will be
3164
+ removed in a future version).
3164
3165
This mode requires a Python database adapter which respect the `Python
3165
3166
DB-API <http://www.python.org/dev/peps/pep-0249/> `__.
3166
3167
@@ -3190,14 +3191,12 @@ engine. You can use a temporary SQLite database where data are stored in
3190
3191
To connect with SQLAlchemy you use the :func: `create_engine ` function to create an engine
3191
3192
object from database URI. You only need to create the engine once per database you are
3192
3193
connecting to.
3193
-
3194
3194
For more information on :func: `create_engine ` and the URI formatting, see the examples
3195
3195
below and the SQLAlchemy `documentation <http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html >`__
3196
3196
3197
3197
.. ipython :: python
3198
3198
3199
3199
from sqlalchemy import create_engine
3200
- from pandas.io import sql
3201
3200
# Create your connection.
3202
3201
engine = create_engine(' sqlite:///:memory:' )
3203
3202
@@ -3280,8 +3279,6 @@ to pass to :func:`pandas.to_datetime`:
3280
3279
3281
3280
You can check if a table exists using :func: `~pandas.io.sql.has_table `
3282
3281
3283
- In addition, the class :class: `~pandas.io.sql.PandasSQLWithEngine ` can be
3284
- instantiated directly for more manual control over the SQL interaction.
3285
3282
3286
3283
Querying
3287
3284
~~~~~~~~
@@ -3310,18 +3307,18 @@ variant appropriate for your database.
3310
3307
3311
3308
.. code-block :: python
3312
3309
3310
+ from pandas.io import sql
3313
3311
sql.execute(' SELECT * FROM table_name' , engine)
3314
-
3315
3312
sql.execute(' INSERT INTO table_name VALUES(?, ?, ?)' , engine, params = [(' id' , 1 , 12.2 , True )])
3316
3313
3317
3314
3318
- In addition, the class :class: `~pandas.io.sql.PandasSQLWithEngine ` can be
3319
- instantiated directly for more manual control over the SQL interaction.
3320
-
3321
-
3322
3315
Engine connection examples
3323
3316
~~~~~~~~~~~~~~~~~~~~~~~~~~
3324
3317
3318
+ To connect with SQLAlchemy you use the :func: `create_engine ` function to create an engine
3319
+ object from database URI. You only need to create the engine once per database you are
3320
+ connecting to.
3321
+
3325
3322
.. code-block :: python
3326
3323
3327
3324
from sqlalchemy import create_engine
@@ -3341,6 +3338,8 @@ Engine connection examples
3341
3338
# or absolute, starting with a slash:
3342
3339
engine = create_engine(' sqlite:////absolute/path/to/foo.db' )
3343
3340
3341
+ For more information see the examples the SQLAlchemy `documentation <http://docs.sqlalchemy.org/en/rel_0_9/core/engines.html >`__
3342
+
3344
3343
3345
3344
Sqlite fallback
3346
3345
~~~~~~~~~~~~~~~
@@ -3354,16 +3353,14 @@ You can create connections like so:
3354
3353
.. code-block :: python
3355
3354
3356
3355
import sqlite3
3357
- from pandas.io import sql
3358
- cnx = sqlite3.connect(' :memory:' )
3356
+ con = sqlite3.connect(' :memory:' )
3359
3357
3360
3358
And then issue the following queries:
3361
3359
3362
3360
.. code-block :: python
3363
3361
3364
3362
data.to_sql(' data' , cnx)
3365
-
3366
- sql.read_sql(" SELECT * FROM data" , cnx)
3363
+ pd.read_sql_query(" SELECT * FROM data" , con)
3367
3364
3368
3365
3369
3366
.. _io.bigquery :
0 commit comments