MCPcopy Create free account
hub / github.com/Freedium-cfd/web / maintenance

Method maintenance

database-lib/database_lib/main.py:242–270  ·  view source on GitHub ↗
(self, time: Optional[int] = None, blocking_time: float = 0.5)

Source from the content-addressed store, hash-verified

240 )
241
242 def maintenance(self, time: Optional[int] = None, blocking_time: float = 0.5):
243 connection = sqlite3.connect(self.database)
244 cursor = connection.cursor()
245 connection.enable_load_extension(True) # Enable loading of extensions
246 connection.execute(
247 "PRAGMA foreign_keys = ON;"
248 ) # Need for working with foreign keys in db
249 connection.execute(
250 "PRAGMA journal_mode=WAL;"
251 ) # Need to properly work with ZSTD compression
252 connection.execute("PRAGMA auto_vacuum=full;") # Same as above thing
253
254 if sqlite_zstd is not None:
255 sqlite_zstd.load(connection)
256
257 with connection:
258 if time is not None:
259 cursor.execute(
260 "SELECT zstd_incremental_maintenance(?, ?);", (time, blocking_time)
261 )
262 else:
263 cursor.execute(
264 "SELECT zstd_incremental_maintenance(null, ?);", (blocking_time,)
265 )
266 cursor.execute("VACUUM")
267 cursor.execute("ANALYZE")
268
269 cursor.close()
270 connection.close()
271
272 def maintenance_thread(self):
273 maintenance_thread = threading.Thread(target=self.maintenance, daemon=True)

Callers 1

enable_maintenance_modeFunction · 0.80

Calls 3

connectMethod · 0.45
loadMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected