This PR corrects the behavior by using the close_with_result connection parameter for the query methods, since they only return one result which is used in the generator, instructing SQLAlchemy to have the ResultProxy cursor close the connection itself once all the results (via the generator) have been consumed. In this case we do not close the connection manually.
When called from the
Database
query methods, theRecord
generator (https://github.com/shacknetisp/records/blob/ab049652ffb11378cd257d751c7e6d557308d841/records.py#L367) accesses theResultProxy
cursor after the database connection has been closed. This causes problems with SQLite in particular (#149).This PR corrects the behavior by using the
close_with_result
connection parameter for the query methods, since they only return one result which is used in the generator, instructing SQLAlchemy to have theResultProxy
cursor close the connection itself once all the results (via the generator) have been consumed. In this case we do not close the connection manually.For more documentation, see https://docs.sqlalchemy.org/en/13/core/connections.html and find "close_with_result".
Fixes #149. Fixes #128. Fixes #189. Closes #177.