def validate_osquery_query(query): # Check if this thread has an instance of the SQLite database db = getattr(osquery_mock_db, 'db', None) if db is None: db = create_mock_db() osquery_mock_db.db = db try: db.execute(query) except sqlite3.Error: return False return True