robmarkcole / HASS-data-detective

Explore and analyse your Home Assistant data
https://data.home-assistant.io/
MIT License
183 stars 34 forks source link

error on db.fetch_all_data() - database disk image is malformed #110

Closed robmarkcole closed 4 years ago

robmarkcole commented 4 years ago
db.fetch_all_data()

Querying the database, this could take a while
Error with query: 
            SELECT domain, entity_id, state, last_changed
            FROM states
            WHERE
                state NOT IN ('unknown', 'unavailable')
            ORDER BY last_changed DESC
            LIMIT :limit

DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
[SQL: 
            SELECT domain, entity_id, state, last_changed
            FROM states
            WHERE
                state NOT IN ('unknown', 'unavailable')
            ORDER BY last_changed DESC
            LIMIT ?
            ]
[parameters: (50000,)]
(Background on this error at: http://sqlalche.me/e/4xp6)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<timed eval> in <module>

~/anaconda3/lib/python3.7/site-packages/detective/core.py in fetch_all_data(self, limit)
    177             self.parse_all_data()
    178         except:
--> 179             raise ValueError("Error querying the database.")
    180 
    181     def parse_all_data(self):

ValueError: Error querying the database.
robmarkcole commented 4 years ago

The corruption most likely since I copied the db over the network

robmarkcole commented 4 years ago

Corruption occured on serveral attempts, 500 MB db. Switched to postgres