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

CoinMarketCap - Issue with HA and mysql DB #9907

Closed
ntalekt opened this issue Oct 16, 2017 · 9 comments
Closed

CoinMarketCap - Issue with HA and mysql DB #9907

ntalekt opened this issue Oct 16, 2017 · 9 comments

Comments

@ntalekt
Copy link

ntalekt commented Oct 16, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.55.1

Python release (python3 --version):
Python 3.4.2

Component/platform:
CoinMarketCap

Description of problem:
Getting sqlite3.OperationalError: unable to open database file when trying to setup the CoinMarketCap component.

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

sensor:
  - platform: coinmarketcap
    currency: ethereum
  1. Add to configuration file
  2. Restart HA and view log

Traceback (if applicable):

2017-10-16 13:40:14 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform coinmarketcap
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 50, in setup_platform
    CoinMarketCapData(currency).update()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 119, in update
    self.ticker = Market().ticker(self.currency, limit=1)
  File "/srv/homeassistant/lib/python3.4/site-packages/coinmarketcap/core.py", line 54, in ticker
    response = self.__request('ticker/' + currency, params)
  File "/srv/homeassistant/lib/python3.4/site-packages/coinmarketcap/core.py", line 28, in __request
    response_object = self.session.get(self.base_url + endpoint, params = params, timeout = self.request_timeout)
  File "/srv/homeassistant/lib/python3.4/site-packages/coinmarketcap/core.py", line 21, in session
    self._session = requests_cache.core.CachedSession(cache_name='coinmarketcap_cache', backend='sqlite', expire_after=120)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/core.py", line 68, in __init__
    self.cache = backends.create_backend(backend, cache_name, backend_options)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/__init__.py", line 50, in create_backend
    return registry[backend_name](cache_name, **options)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/sqlite.py", line 28, in __init__
    self.responses = DbPickleDict(location + extension, 'responses', fast_save=fast_save)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/storage/dbdict.py", line 58, in __init__
    with self.connection() as con:
  File "/usr/lib/python3.4/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/storage/dbdict.py", line 70, in connection
    con = sqlite.connect(self.filename)
sqlite3.OperationalError: unable to open database file

Additional info:

@jalbarracinv
Copy link

jalbarracinv commented Oct 17, 2017

Same problem... started when updated to last version I think.

2017-10-16 02:36:26 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform coinmarketcap
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 50, in setup_platform
    CoinMarketCapData(currency).update()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 119, in update
    self.ticker = Market().ticker(self.currency, limit=1)
  File "/srv/homeassistant/lib/python3.4/site-packages/coinmarketcap/core.py", line 54, in ticker
    response = self.__request('ticker/' + currency, params)
  File "/srv/homeassistant/lib/python3.4/site-packages/coinmarketcap/core.py", line 28, in __request
    response_object = self.session.get(self.base_url + endpoint, params = params, timeout = self.request_timeout)
  File "/srv/homeassistant/lib/python3.4/site-packages/coinmarketcap/core.py", line 21, in session
    self._session = requests_cache.core.CachedSession(cache_name='coinmarketcap_cache', backend='sqlite', expire_after=120)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/core.py", line 68, in __init__
    self.cache = backends.create_backend(backend, cache_name, backend_options)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/__init__.py", line 50, in create_backend
    return registry[backend_name](cache_name, **options)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/sqlite.py", line 28, in __init__
    self.responses = DbPickleDict(location + extension, 'responses', fast_save=fast_save)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/storage/dbdict.py", line 58, in __init__
    with self.connection() as con:
  File "/usr/lib/python3.4/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests_cache/backends/storage/dbdict.py", line 70, in connection
    con = sqlite.connect(self.filename)
sqlite3.OperationalError: unable to open database file

@bobnwk
Copy link
Contributor

bobnwk commented Nov 12, 2017

Different issue. Home Assistant version 0.57.3.

  - platform: coinmarketcap
    currency: bitcoin
    display_currency: EUR
2017-11-12 19:16:23 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform coinmarketcap
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 55, in setup_platform
    CoinMarketCapData(currency, display_currency).update()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/coinmarketcap.py", line 129, in update
    from coinmarketcap import Market
  File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/__init__.py", line 10, in <module>
    from .core import Market
  File "/srv/homeassistant/lib/python3.5/site-packages/coinmarketcap/core.py", line 6, in <module>
    import requests_cache
  File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/__init__.py", line 28, in <module>
    from .core import(
  File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/core.py", line 21, in <module>
    ver = tuple(map(int, requests.__version__.split(".")))
AttributeError: module 'pip._vendor.requests.__version__' has no attribute 'split'

@scottsweb
Copy link

As above I am getting errors:

- platform: coinmarketcap
    currency: bitcoin
    display_currency: GBP
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/coinmarketcap.py", line 55, in setup_platform
    CoinMarketCapData(currency, display_currency).update()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/coinmarketcap.py", line 129, in update
    from coinmarketcap import Market
  File "/config/deps/lib/python3.5/site-packages/coinmarketcap/__init__.py", line 10, in <module>
    from .core import Market
  File "/config/deps/lib/python3.5/site-packages/coinmarketcap/core.py", line 6, in <module>
    import requests_cache
  File "/config/deps/lib/python3.5/site-packages/requests_cache/__init__.py", line 28, in <module>
    from .core import(
  File "/config/deps/lib/python3.5/site-packages/requests_cache/core.py", line 21, in <module>
    ver = tuple(map(int, requests.__version__.split(".")))
AttributeError: module 'pip._vendor.requests.__version__' has no attribute 'split'```

@craigcarps
Copy link

I can confirm I have the same issue as ntalekt

@frittes
Copy link
Contributor

frittes commented Dec 27, 2017

I have the same error since October. I do not think the mysql db is the problem. Usually the sensor creates a sqlite cache db and that does not work. For me permissions are ok, but the file is not created at startup of HA.

Could anyone of the python pros please take a look for a solution of this problem?

@MartinHjelmare
Copy link
Member

This is a problem within the coinmarketcap library. When there's a fix there, we can upgrade home assistant to use the fix. Follow barnumbirr/coinmarketcap#23 for updates.

@Klathmon
Copy link
Contributor

Klathmon commented Dec 30, 2017

A workaround for now is to change line 21 in the coinmarketcap package from backend='sqlite' to backend='memory'.

By default it should be located at path/to/your/venv/lib/python#.#/site-packages/coinmarketcap/core.py, although I don't know if changing it there is the best idea, as I'm not sure how HASS will handle updates, so beware of that.

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@MartinHjelmare
Copy link
Member

Should be fixed in #11953.

@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants