File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -5526,13 +5526,23 @@ below and the SQLAlchemy `documentation <https://docs.sqlalchemy.org/en/latest/c
5526
5526
# Create your engine.
5527
5527
engine = create_engine(" sqlite:///:memory:" )
5528
5528
5529
- If you want to manage your own connections you can pass one of those instead:
5529
+ If you want to manage your own connections you can pass one of those instead. The example below opens a
5530
+ connection to the database using a Python context manager that automatically closes the connection after
5531
+ the block has completed.
5532
+ See the `SQLAlchemy docs <https://docs.sqlalchemy.org/en/latest/core/connections.html#basic-usage >`__
5533
+ for an explanation of how the database connection is handled.
5530
5534
5531
5535
.. code-block :: python
5532
5536
5533
5537
with engine.connect() as conn, conn.begin():
5534
5538
data = pd.read_sql_table(" data" , conn)
5535
5539
5540
+ .. warning ::
5541
+
5542
+ When you open a connection to a database you are also responsible for closing it.
5543
+ Side effects of leaving a connection open may include locking the database or
5544
+ other breaking behaviour.
5545
+
5536
5546
Writing DataFrames
5537
5547
''''''''''''''''''
5538
5548
You can’t perform that action at this time.
0 commit comments