more correct way optimizing sqlite database
This commit is contained in:
parent
e762f1e7f6
commit
8c81fe5c5e
1 changed files with 10 additions and 3 deletions
13
ubot.py
13
ubot.py
|
@ -115,12 +115,19 @@ async def main():
|
|||
)''')
|
||||
conn.commit()
|
||||
logger.debug('sqlite3 database initialized')
|
||||
logger.debug('optimizing database...')
|
||||
c.execute('PRAGMA optimize')
|
||||
c.execute('PRAGMA optimize=0x10002')
|
||||
c.execute('PRAGMA journal_mode = WAL')
|
||||
c.execute('PRAGMA synchronous = normal')
|
||||
logger.debug('Vacuuming database...')
|
||||
c.execute('VACUUM')
|
||||
logger.debug('optimized')
|
||||
logger.debug('Vacuum done')
|
||||
|
||||
async def optimize_sqlite_db():
|
||||
while True:
|
||||
c.execute('PRAGMA optimize')
|
||||
logger.debug('database optimized')
|
||||
await asyncio.sleep(12 * 60 * 60)
|
||||
asyncio.ensure_future(optimize_sqlite_db())
|
||||
|
||||
####################################################################
|
||||
|
||||
|
|
Loading…
Reference in a new issue