Code Monkey home page Code Monkey logo

Comments (3)

ZZDDD avatar ZZDDD commented on July 23, 2024

According to #150 , I modified the code given by:
https://stackoverflow.com/questions/75316741/attributeerror-engine-object-has-no-attribute-execute-when-trying-to-run-sq/75316945#75316945
in the core.py file, line 74 to:

with self.engine.connect() as conn:
    return conn.execute(query, params)

However, this didn't work when running the notebook section:
db = detective.HassDatabase(db_url) # To init without fetching entities fetch_entities=False
and threw the following error:

Successfully connected to database sqlite:////home/config/.homeassistant/home-assistant_v2.db
Error with query:
SELECT DISTINCT(entity_id) FROM states

(sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/14/e3q8)

OperationalError: (sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/14/e3q8)

After this, I tried to change the sqlalchemy version to 1.4.x by:

pip install sqlalchemy==1.4.1
and run the same section:
db = detective.HassDatabase(db_url) # To init without fetching entities fetch_entities=False
This still got the same error.

But interestingly, the section:
db = detective.db_from_hass_config()
worked! The output is:

Successfully connected to database sqlite:////config/home-assistant_v2.db
There are 89 entities with data
Entities are listed on an attribute

So, what could be done to solve this problem? Is there any better ways to modified the code so that it could adapt the 2.0.x version of sqlalchemy?

from hass-data-detective.

robmarkcole avatar robmarkcole commented on July 23, 2024

resolved with

    def perform_query(self, query, **params):
        """Perform a query."""
        try:
            with self.engine.connect() as conn:
                return conn.execute(query, params)
        except:
            print(f"Error with query: {query}")
            raise

from hass-data-detective.

martin3000 avatar martin3000 commented on July 23, 2024

This means that HASS-data-detective only runs with HA 2023.4 and newer. In older versions, there is no state_meta and HASS-data-detective 2.6 does not work because it uses engine.execute()

from hass-data-detective.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.