piskvorky / sqlitedict

Persistent dict, backed by sqlite3 and pickle, multithread-safe.
Apache License 2.0
1.16k stars 130 forks source link

sqlite3.DatabaseError: database disk image is malformed #149

Open instasck opened 2 years ago

instasck commented 2 years ago

After power down I got this issue on many files. Other sqlite3 files were working well.

class nestedDictSqlite(defaultdict):
    'like defaultdict but default_factory receives the key so table is used to form first argument'

    def __missing__(self, table):
        self[table] = value = self.default_factory(table)
        return value

InstaPyLimits.limiter_db = nestedDictSqlite(
            lambda table: SqliteDict(filename='{}{}_limiter.db'.format(Settings.limiter_database_location, user_id),
                                     tablename=table, flag='c', autocommit=True, encode=json.dumps, decode=json.loads))

image

What can it be ?