Skip to content

DOC GH29075 close database connections after creation #42277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2021

Conversation

TAJD
Copy link
Contributor

@TAJD TAJD commented Jun 28, 2021

I've expanded on the use of a context manager to handle the closing of the database connection after the connection has been opened. I've also included a warning at the end of the section highlighting problems with leaving the database connection open. I think these additions tackle the docs problem associated with this issue.

Whilst psycopg2 is supported through sqlalchemy it appears to not be explicitly supported in its own right. I linked to the section in the sqlalchemy docs which discusses what happens when you use a Python context manager to handle connecting to a database. Hopefully users will now have a better idea on how or why database connections are being made in the recommended manner and can access the relevant documentation quickly.

@jreback jreback added Docs IO SQL to_sql, read_sql, read_sql_query labels Jun 28, 2021
@jreback jreback added this to the 1.3 milestone Jun 28, 2021
@jreback jreback merged commit b8c8aca into pandas-dev:master Jun 28, 2021
@jreback
Copy link
Contributor

jreback commented Jun 28, 2021

thanks @TAJD

@jreback
Copy link
Contributor

jreback commented Jun 28, 2021

@meeseeksdev backport 1.3.x

@lumberbot-app
Copy link

lumberbot-app bot commented Jun 28, 2021

Something went wrong ... Please have a look at my logs.

@TAJD TAJD deleted the db_conn_docs branch June 28, 2021 16:01
simonjayhawkins pushed a commit that referenced this pull request Jun 28, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing a psycopg2 connection to read_sql can cause table locks
2 participants