-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
DatabaseError('database disk image is malformed') #1573
Comments
Try GitHub branch |
It works. Thanks a lot! |
Since today, the DatabaseError comes up again, but with peewee.
Error message in file. |
Re-patching will take time as the caching has completely changed since the previous patch. Quickest fix should be deleting the database: https://github.com/ranaroussi/yfinance#persistent-cache-store |
First, I deleted the database in C:\Users<USER>\AppData\Local\py-yfinance as suggested. But it didn't help. After searching for other locations, I found C:\Users<USER>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\Local\py-finance. This one did the fix. Not sure, if it has something to do that I worked in a virtual environment. |
Patch in branch |
Problem
I cannot download historical stock data with yfinance
Simple code that reproduces your problem
data = yf.download("SPY", start="2017-01-01", end="2017-04-30")
Full debug logging enabled output
DEBUG Entering download()
DEBUG Disabling multithreading because DEBUG logging enabled
DEBUG Entering history()
ERROR
1 Failed download:
ERROR ['SPY']: DatabaseError('database disk image is malformed')
DEBUG ['SPY']: Traceback (most recent call last):
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\multi.py", line 273, in _download_one
data = Ticker(ticker, session=session).history(
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\utils.py", line 105, in wrapper
result = func(*args, **kwargs)
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\base.py", line 153, in history
tz = self._get_ticker_tz(proxy, timeout)
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\base.py", line 1409, in _get_ticker_tz
cache = utils.get_tz_cache()
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\utils.py", line 1045, in get_tz_cache
_tz_cache = _TzCache()
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\utils.py", line 958, in init
self._tz_db = _KVStore(_os.path.join(self._db_dir, "tkr-tz.db"))
File "C:\Users\harry\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\yfinance\utils.py", line 900, in init
self.conn.execute('pragma journal_mode=wal')
sqlite3.DatabaseError: database disk image is malformed
DEBUG Exiting download()
Version
yfinance
version: 0.2.21The text was updated successfully, but these errors were encountered: