Skip to content
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 driver not installed! #2124

Open
dsoeiro opened this issue Nov 13, 2024 · 3 comments
Open

SQLite driver not installed! #2124

dsoeiro opened this issue Nov 13, 2024 · 3 comments

Comments

@dsoeiro
Copy link

dsoeiro commented Nov 13, 2024

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

@ValueRaider
Copy link
Collaborator

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:

self.dummy = True

@dsoeiro
Copy link
Author

dsoeiro commented Nov 13, 2024

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?

@ValueRaider
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants