yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

SQLite driver not installed!

Open dsoeiro opened this issue 1 year ago • 3 comments

Describe bug

When running the Google Cloud Function with the latest version of Python and yfinance, the error SQLite driver not installed! occurred. This issue arose because the yfinance library attempts to use SQLite for caching, but the required SQLite driver is not available in the Cloud Function environment. As a result, the function failed to retrieve data properly (response: 'SQLite driver not installed!'). However, when using an older version like yfinance==0.1.63, it works, but returns zero results. If you run the same code locally with the latest version of both Python and yfinance, it works normally without any issues.

Simple code that reproduces your problem

from flask import jsonify, abort, request import yfinance as yf

def main(request):

request_json = request.get_json(silent=True)
symbol = request_json.get("symbol") if request_json else None

if not symbol:
    abort(400, "Symbol is required")

try:

    company = yf.Ticker(symbol)
    stock_info = {
        'market_cap': company.info.get('marketCap', None),
        'avg_volume': company.info.get('averageVolume', None),
        'dividend_yield': company.info.get('dividendYield', None),
        'forward_pe': company.info.get('forwardPE', None),
        'beta': company.info.get('beta', None),
        'profit_margins': company.info.get('profitMargins', None),
        'return_on_assets': company.info.get('returnOnAssets', None),
        'return_on_equity': company.info.get('returnOnEquity', None),
    }
    return jsonify(stock_info)
except Exception as e:
    return jsonify({"error": str(e)}), 500

request

response


requirements.txt

flask yfinance

Debug log

https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL textPayload: "DEBUG params={'modules': 'financialData,quoteType,defaultKeyStatistics,assetProfile,summaryDetail', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false', 'symbol': 'AAPL'}"

textPayload: "DEBUG cookie_mode = 'basic'"

textPayload: "DEBUG Entering _get_cookie_and_crumb()"

Bad data proof

No response

yfinance version

last

Python version

Python 3.12

Operating system

No response

dsoeiro avatar Nov 13 '24 03:11 dsoeiro

yfinance/cache.py already has logic for coping with a read-only cache folder, so probably it can be extended to also handle sqlite missing: https://github.com/ranaroussi/yfinance/blob/dfe3ec8df7be8da5e6addc629ed8dfa95e2f896d/yfinance/cache.py#L133

ValueRaider avatar Nov 13 '24 18:11 ValueRaider

thanks @ValueRaider . Understood, thank you for the explanation. Is there anything I can contribute to help address this point? For example, would additional testing in environments where SQLite is unavailable be useful, or is there another way I could support this implementation?

dsoeiro avatar Nov 13 '24 23:11 dsoeiro

You could develop and test a fix for missing sqlite? #1084

ValueRaider avatar Nov 14 '24 21:11 ValueRaider