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
'sqlite:///:memory:' is OK while sqlite:///db.sqlite
fails with Cannot operate on a closed database.
#149
Comments
Doublechecking my test modifications to make sure, it is not introduced by test only:
By "test" I mean one test case (function call, e.g. My estimation is, the close on file based sqlite database is somehow surviving across multiple test calls and later attempts are failing due to database being already closed. |
Queries can be run against:
The problems are with Fetching from queries run via connection are fine, e.g. Narrowing the problem definition: When database object is created from file-based sqlite database, any attempt to fetch query results from query run on such database fails with an error If the sqlite database is memory based, the problem does not happen. Original test suite tested queries only against in-memory sqlite database. Refactored test suite preserves all original cases and adds test variant with file-based sqlite database. All tests run against in-memory database are passing. Test cases with file-based sqlite database which do not fetch from query run directly on database are fine too (these queries are run against connection). To run one failing case: $ pytest -sv tests/test_transactions.py::test_plain_db[sqlite_file] or all of them: $ pytest -sv tests/test_transactions.py -k sqlite_file |
In my research/testing, I've found that the issue is the context manager in Database.query() is closing the Connection object before you've had a chance to retrieve the records. I tried remove the with block, instead going with: |
Not sure if this issue has been fixed with the May 7/12 merges, but just wanted to note that this error arises when using the $ records 'select * from things' csv --url sqlite:///mythings.sqlite
|
Has this fix been released? It looks like the patch was integrated on May 7 2019 but I just installed the master branch via
|
Fixes kennethreitz#149. Fixes kennethreitz#128. Fixes kennethreitz#189. Closes kennethreitz#177.
Thank you! |
Run
and see, that when the test runs with in-memory sqlite database, all cases are passing, but if it is using real file, it fails in all but one case.
The failure shows tracebacks such as:
The text was updated successfully, but these errors were encountered: