'sqlite:///:memory:' is OK while `sqlite:///db.sqlite` fails with `Cannot operate on a closed database.`
See original GitHub issueRun
$ pytest -sv tests/test_transactions.py
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:
Traceback (most recent call last):
File "/home/javl/sandbox/playwith_records/records/.tox/py36/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 1186, in fetchone
row = self._fetchone_impl()
File "/home/javl/sandbox/playwith_records/records/.tox/py36/lib/python3.6/site-packages/sqlalchemy/engine/result.py", line 1067, in _fetchone_impl
return self.cursor.fetchone()
sqlite3.ProgrammingError: Cannot operate on a closed database.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/javl/sandbox/playwith_records/records/.tox/py36/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1288, in _safe_close_cursor
cursor.close()
sqlite3.ProgrammingError: Cannot operate on a closed database.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Cannot operate on a closed database. [Python] [sqlite] - Stack ...
You write "It seems to me like the connection to the database is not closed before the second connection is attempted" but, in...
Read more >In-Memory Databases - SQLite
The database ceases to exist as soon as the database connection is closed. Every :memory: database is distinct from every other. So, opening...
Read more >Connecting To SQLite Database Using Node.js
If an error occurred, the error object is not null , otherwise, it is null . If you don't provide the callback function...
Read more >SQLite - SQLAlchemy 1.4 Documentation
The SQLite database supports transactional DDL as well. In this case, the pysqlite driver is not only failing to start transactions, it also...
Read more >Database — peewee 3.15.4 documentation
from peewee import * # SQLite database using WAL journal mode and 64MB ... These statements are typically run when a new database...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Has this fix been released? It looks like the patch was integrated on May 7 2019 but I just installed the master branch via
pipenv install git+https://github.com/kennethreitz/records.git@master#egg=records
and I’m still seeing this bug when trying to access a local sqlite3 database: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
command-line tool: