Skip to content

Commit b8c8aca

Browse files
authored
DOC GH29075 specify requirement to close database connections after creation (pandas-dev#42277)
1 parent 73ed010 commit b8c8aca

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

doc/source/user_guide/io.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -5526,13 +5526,23 @@ below and the SQLAlchemy `documentation <https://docs.sqlalchemy.org/en/latest/c
55265526
# Create your engine.
55275527
engine = create_engine("sqlite:///:memory:")
55285528
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.
55305534

55315535
.. code-block:: python
55325536
55335537
with engine.connect() as conn, conn.begin():
55345538
data = pd.read_sql_table("data", conn)
55355539
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+
55365546
Writing DataFrames
55375547
''''''''''''''''''
55385548

0 commit comments

Comments
 (0)