forked from enessari/metabase-ai-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprobe_test.js
More file actions
41 lines (33 loc) · 1.33 KB
/
probe_test.js
File metadata and controls
41 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { MetabaseClient } from './src/metabase/client.js';
import dotenv from 'dotenv';
import { join } from 'path';
dotenv.config({ path: join(process.cwd(), '.env') });
async function main() {
console.log("🚀 Probing Data Visibility...");
// Remove API KEY from options to FORCE Username/Password auth
const client = new MetabaseClient({
url: process.env.METABASE_URL,
username: process.env.METABASE_USERNAME,
password: process.env.METABASE_PASSWORD
});
try {
await client.authenticate();
console.log("✅ API Authenticated (User/Pass)");
} catch (e) {
console.error("❌ Authentication Failed:", e.message);
process.exit(1);
}
const internalDbId = 6;
try {
console.log(`\n🔍 Querying report_card on DB ${internalDbId}...`);
const res = await client.executeNativeQuery(internalDbId, "SELECT count(*) FROM report_card", { enforcePrefix: false });
if (res.rows && res.rows.length > 0) {
console.log(`✅ SUCCESS: Found ${res.rows[0][0]} cards in report_card!`);
} else {
console.log("⚠️ Query success but returned 0 rows.");
}
} catch (e) {
console.error(`❌ Failed to query Internal DB (ID ${internalDbId}):`, e.message);
}
}
main().catch(err => console.error(err));