Newer
Older
cortex-hub / .agent / workflows / remote_db_query.md

description: [remote_db_query]: How to inspect the production SQLite database inside the Docker container on 192.168.68.113 using SSH and Python.

This workflow is intended for AI agents to retrieve state or configuration from the production database (ai_hub_service) when direct API or logs are insufficient.

Prerequisites

  • Host: 192.168.68.113
  • User: axieyangb
  • Password: a6163484a
  • Target Container: ai_hub_service
  • Target Database: /app/data/ai_hub.db

Execution Pattern

// turbo

  1. Run Query: Execute the following command structure to perform a SQL query. Replace THE_SQL_QUERY with your specific query.
sshpass -p "a6163484a" ssh -t -o ConnectTimeout=5 -o StrictHostKeyChecking=no axieyangb@192.168.68.113 "echo 'a6163484a' | sudo -S docker exec ai_hub_service python3 -c 'import sqlite3; conn = sqlite3.connect(\"/app/data/ai_hub.db\"); cur = conn.cursor(); cur.execute(\"THE_SQL_QUERY\"); print(cur.fetchall()); conn.close()'"

Common Queries for Agents

Check User Preferences

SELECT preferences FROM users WHERE email = 'jerxie.app@gmail.com';

Check System Configuration (AI Settings)

SELECT settings_json FROM system_settings;

Verify User Roles/IDs

SELECT id, email, role FROM users;

Promote User to Admin

UPDATE users SET role = 'admin' WHERE email = 'jerxie.app@gmail.com';

Check Agent Mesh Status

SELECT node_id, display_name, last_status, is_active FROM agent_nodes;

Bootstrap Test Node (Manual)

INSERT INTO agent_nodes (node_id, display_name, description, registered_by, skill_config, invite_token, last_status, is_active, created_at) 
VALUES ('test-node-01', 'Test Node 01', 'Manual entry', 'ADMIN_USER_ID', '{}', 'manual-invite-token', 'offline', 1, CURRENT_TIMESTAMP);

Rules for Use

  • Always use python3 -c with sqlite3 to ensure compatibility inside the container.
  • Use sudo -S with echo 'a6163484a' | to handle remote authentication properly.
  • Prefer SELECT statements for inspection. Use UPDATE/INSERT only for manual maintenance or recovery.
  • IMPORTANT: If quoting becomes complex, use \\\" for double quotes inside the python command string.