-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
AttributeError: 'str' object has no attribute '_execute_on_connection' #157
Comments
Make sure you are using a virtual env - there were changes in sqlalchemy==2.0.7 |
Could you expand? I'm not sure if this is what @rorso meant, but I'm also running HAOS in an x86 VM (e.g. with supervisor & the HACA JupyterLab add-on), and getting the same error. Although I'm guessing it is inconsequential per the DB connect success that I'm seeing, I'm also running the official MariaDB add-on. I can't see any (er, obvious to me) way to run/change a venv in this setup, although I did try adding a cell immediately following TIA! |
I'm really sorry. It may be obvious to you, but not to me. "Just do lfakjsasjfladjfhal" sounds like a magic spell to me. There are people outside that are not digital natives, although I follow the technology a couple of decades now. But I did try to get enlightened about "virtual env". It seems that I have to mess around heavily with the way my HA installation is running - which will not happen. I'm glad that it works great as is and I see no point in a total rework of my installation just to get this python script running, no matter how useful it might be. |
Sorry, I think I was misunderstood 🙂. I was asking robmarkcole for more information about what he meant by using a virtual env (for what it's worth, I'm glad you didn't mess with your HA -- this add-on is a docker container, so AFAIK, any changes to the virtual env (aka venv) would need to be inside the docker container (each HA Add-on being in essence, a lightweight VM running inside our HA VMs)). Anyway, I only happened to mention your username as, like you, I also happen to be running HA as a virtual machine -- in case this is relevant to the issue at hand. Cheers; |
Some info on virtual environments: https://docs.python.org/3/tutorial/venv.html This repository readme also include instructions for how to run detective in Docker The issue here is I suspect the python environment people are installing this package into has some conflicting requirements, so the way to rule this out is by using a virtual or isolated environment |
Actually, this is an issue unique to home assistant's addon. It is out of date. For a better experience in jupyter "File" -> "Open From URL" and use the link here. Then all is right with the world! |
Thank you! This gets me almost running. Hopefully the addon will be updated soon. |
I think the issue here is with how the "perform_query" function is being called. It's setup to accept queries in the form of sqlalchemy text clauses, but the notebook has the function accepting a raw string. To use the perform_query function, you need: from sqlalchemy import text db.perform_query(text('SELECT * FROM events')) Right? |
This is what worked for me. I am using a Postgres database as the back-end, so not sure if that affects how these functions work. |
I just installed the JupterLabs AddOn to HA, Version | core-2024.8.3 and low and behold I'm getting this attribute error. JupyterLab Current version: 0.15.2
Am I to assume this AddOn is still broke? I performed the File/Open from URL as mentioned earlier and that worked.
|
This seems to be an an old issue/confusing issue. If anyone tries Home Assistant Data Science which is linked from home-assistant.io pages, it no longer works and appears to have not worked since spring of 2023. The problem may not be in this module, HASS-data-detective but may that the JupyterLab from Frenck in the Home Assistant Community Add-on store, https://github.com/hassio-addons/addon-jupyterlab has got old versions of Hass-data-detective, SQLAlchemy, and possibly other modules(*) (* I didn't follow all the SQLalchemy discussion in this issue to see if just a newer version of SQLAlchemy fixes things or not. I did try the workaround of importing text from sqlalchemy and wrapping the event query from
|
I think the best action is to open an issue in the addon as I'm not sure how actively it is updated |
Done, github already linked it here: hassio-addons/addon-jupyterlab#634 Note the add-on currently contains version 3.0, from the
The addon is using 2.0.35 of sqlalchemy.
I see that 3.1 was released two weeks ago, but it looks like So does your module still work with current (2024.10.x) Home Assistant as long as sqlalchemy 2.0.7 (from March 2023) is used? |
I vaguely remember there was a breaking change in sqlalchemy.. best thing is to try it |
First, thanks for getting back to me so quickly. I'll try to setup a Jupyter environment where I can easily test this (conda doesn't like pip installs). I'm not sure if it is the cause or not, but see above in this issue about sqlalchemy needing text vs. raw: #157 (comment) |
More info: It also appears that the notebook in the add-on, That notebook seems to work (with a few warnings and last_updated_ts doesn't get displayed correctly) with sqlalchemy 2.0.35 in the add-on. See @geiseri comment above in this issue: #157 (comment) So I don't know if the problem is more to do with the notebook or the version of alchemy Also here is the add-on's requirements: https://github.com/hassio-addons/addon-jupyterlab/blob/main/jupyterlab/requirements.txt
Maybe getting Frenck (or whoever has access to that repo to pull in 3.1 would make things work. |
There might be some reason for not upgrading the dependency in the add on - not sure |
To be clear, the add-on uses the current version of sqlalchemy, not the version required by requirements.txt from HASS-data-detective. However, doing some more digging and testing I found: The example notebook in the add-on fails because it calls I created a local venv, cloned your repo, pip installed requirements and tests. The existing tests succeed. However, even with sqlalchemy==2.0.7, running `db.perform_query("SELECT 1;") fails with the same underlying error "ObjectNotExecutableError: Not an executable object. Should something like `db.perform_query("SELECT 1;") work, or does perform_query need something other than a string? |
Ok there is a bug here then |
I'm failing to see how this is an add-on issue. IMHO the issues are downstream, so not really sure what you want me to do here. ../Frenck |
Frenck wrote:
Now that it is understood to be a problem with the HASS-data-detective module and not the notebooks pulled in from home-assistant-notebooks, nothing until a fixed version of this module is available. |
Running the supplied GETTING_STARTED.ipynb it stops with the following error:
I tried this running on HA with Jupyter Lab 0.10.2
HA is running in a virtual machine on X86.
The information on starting:
The text was updated successfully, but these errors were encountered: