[RESOLVED] Make changes directly in

Happy with my nice dashboards, I started running tests with my different devices, notably some fake MQTT devices.
One in particular: a fake device that receives from Node-RED data about my daily electrical consumption.

But this device is supposed to receive data only once a day, which allows me to display a nice histogram.

Except that while testing, I sent data several times today… which broke my chart!! It looked great and now it doesn’t look like anything.

Is there a way to delete these « undesirable » entries from my DB? (especially since I didn’t know much about SQLite… and even less about DuckDB ^^ )

I also need to make some adjustments in the database, to correct a solar production reading that failed three nights in a row, and everything piled up on the 4th night… So if there’s a tool to browse the DuckDB database and modify values, I’ll take it :wink:

I haven’t tried it, but in the DuckDB docs it recommends a tool

2 Likes

Otherwise you can use https://tableplus.com/ :slight_smile:

  • Pause your Gladys instance (docker stop gladys)
  • Download the DuckDB database file to your machine (with a tool like Cyberduck or FileZilla it works very well)
  • Open the file in TablePlus and delete the line that causes the problem
  • Save and quit TablePlus
  • Re-upload the file with Cyberduck/FileZilla
  • Restart Gladys (docker restart gladys)

Be careful not to mess up the file ^^

2 Likes

It’s simpler than I imagined :wink:

Yes, we’ll avoid making a mess; anyway, when I do this I usually copy the file to have a backup just in case!

Thanks for your advice!

However… I don’t know which type of database to choose in TablePlus :thinking:

Normally you use SQLite from what I read on GitHub. But it didn’t work for me (empty table ^^).

Same here… Nothing at all.

I tried DBeaver, but when I go look for the table t_device_feature_state since I imagine that’s the right one, the most recent values are from the day before yesterday… :thinking: How is that possible?

Does that correspond to 48h « exactly »?

To confirm with @pierre-gilles, but the data on this timeline may be stored in memory then transferred to the file…

I’ll take a look!!

EDIT: No storage in « memory ».

From what I see, unlike the SQL DB, when we stop gladys, duckdb’s .duckdb.wal remains and is more recent than the .duckdb … Can you confirm? What are the dates and times of the two files for you?
image

For my part I only have 1 hour of inaccessible data (which corresponds to the time difference between the files - 9:52 vs 10:48):

Are you on Windows? I’m on macOS and I do have DuckDB in TablePlus, but apparently the other versions don’t have this DB yet. In your case, you should use DBeaver :slight_smile:

Indeed, you must copy the two files (.duckdb + .duckdb.wal), and of course copy them only if Gladys is stopped.

Yep for me! macOS often a step ahead ^^

That’s the case, but when Gladys is stopped (via docker stop gladys) as mentioned above, the .wal is still present (unlike the SQL db) and there is 1 hour of « missing » data (clearly present on the graphs) in Gladys.

Hello @_Will_71 ,

I’ve been using DBeaver professionally (DB2, MS SQL, MuSQL, PgSQL …) and personally (SQLite) for quite a while now, and it’s a great tool. Because data access is done visually, in table form (spreadsheet-style), you can easily edit the data :slight_smile:
Have a nice day,
Jean

I usually use TablePlus but on Linux it’s not yet possible to open a DuckDB database.
I’ll therefore try this tool.

Yes, and if you copy both files correctly and open the file in DBeaver, you should have all the data, right?

:sweat_smile: no ^^ well — still -1h. And when I disconnect from the DB in DBeaver, this time the .wal is deleted!^^

I tried DBeaver Community, but a small problem: on my Gladys server running Linux DBeaver sees the database but returns an « access denied ».
A DBeaver Community on a Windows PC sees the local databases but not the network-accessible databases

@Einstein8854 did you duplicate it properly or at least stop Gladys before accessing it? It’s a single connection. You can’t access it at the same time as Gladys is running.

Well, clearly things are never simple :stuck_out_tongue_winking_eye:

I retrieved my file, I found records that interested me, and I deleted them in DBeaver.

But when I tried to re-transfer my database to my server… FileZilla wouldn’t cooperate and refused to write to the directory.
So I had to temporarily change the permissions of the gladysassistant folder to be able to copy my modified file there.

It’s done… and everything’s working!!!

Thanks again everyone for your help :slight_smile:

BEFORE :

AFTER :

2 Likes

Ok, weird ^^ Sorry I don’t use DBeaver; you’ll have to check if there’s some subtlety.

Maybe the DuckDB documentation might be helpful:

Hello @guim31

This brings up again a topic that had been discussed regarding starting a container as a user other than « root »: could we create a thread to establish good containerization practices?

Have a nice day,
Jean