-
Notifications
You must be signed in to change notification settings - Fork 312
Expand file tree
/
Copy pathquery_rf_form.js
More file actions
66 lines (56 loc) · 1.66 KB
/
Copy pathquery_rf_form.js
File metadata and controls
66 lines (56 loc) · 1.66 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const { Pool } = require('pg');
async function queryRfForm() {
const pool = new Pool({
host: '192.168.1.136',
port: 35438,
user: 'postgres',
database: 'roadflow',
password: 'Hxkj510510'
});
try {
// 查看列定义
const colResult = await pool.query(`
SELECT column_name, data_type
FROM information_schema.columns
WHERE table_name = 'rf_form'
ORDER BY ordinal_position
`);
console.log('📋 rf_form 表的列定义:');
colResult.rows.forEach(row => {
console.log(' -', row.column_name.padEnd(20), '|', row.data_type);
});
// 查看现有记录数
const countResult = await pool.query("SELECT COUNT(*) as cnt FROM rf_form");
console.log('\n📊 rf_form 表当前记录数:', countResult.rows[0].cnt);
// 显示所有现有表单
const forms = await pool.query(`
SELECT id, name, createtime
FROM rf_form
ORDER BY createtime DESC
LIMIT 15
`);
if (forms.rows && forms.rows.length > 0) {
console.log('\n📋 现有的表单记录:');
forms.rows.forEach(row => {
console.log(' ID:', row.id, '|', row.name);
});
} else {
console.log(' ⚠️ rf_form 表暂无数据');
}
// 显示完整的一条记录示例
const sample = await pool.query(`
SELECT * FROM rf_form
ORDER BY createtime DESC
LIMIT 1
`);
if (sample.rows && sample.rows.length > 0) {
console.log('\n📝 最近一条记录的完整内容:');
console.table(sample.rows[0]);
}
} catch (error) {
console.error('\n❌ 错误:', error.message);
} finally {
await pool.end();
}
}
queryRfForm();