55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
const sqlite3 = require('sqlite3').verbose();
|
|||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
// 创建SQLite数据库连接
|
||
|
|
const dbPath = path.join(__dirname, 'company_finance.db');
|
||
|
|
const db = new sqlite3.Database(dbPath, (err) => {
|
||
|
|
if (err) {
|
||
|
|
console.error('数据库连接失败:', err.message);
|
||
|
|
} else {
|
||
|
|
console.log('SQLite数据库连接成功');
|
||
|
|
checkTableStructure();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 检查表结构
|
||
|
|
function checkTableStructure() {
|
||
|
|
console.log('开始检查表结构...');
|
||
|
|
|
||
|
|
// 检查projects表结构
|
||
|
|
db.all('PRAGMA table_info(projects)', (err, rows) => {
|
||
|
|
if (err) {
|
||
|
|
console.error('检查projects表结构失败:', err.message);
|
||
|
|
} else {
|
||
|
|
console.log('projects表结构:');
|
||
|
|
rows.forEach(row => {
|
||
|
|
console.log(row.name + ' (' + row.type + ')');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 检查expenses表结构
|
||
|
|
db.all('PRAGMA table_info(expenses)', (err, rows) => {
|
||
|
|
if (err) {
|
||
|
|
console.error('检查expenses表结构失败:', err.message);
|
||
|
|
} else {
|
||
|
|
console.log('\nexpenses表结构:');
|
||
|
|
rows.forEach(row => {
|
||
|
|
console.log(row.name + ' (' + row.type + ')');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 检查tasks表结构
|
||
|
|
db.all('PRAGMA table_info(tasks)', (err, rows) => {
|
||
|
|
if (err) {
|
||
|
|
console.error('检查tasks表结构失败:', err.message);
|
||
|
|
} else {
|
||
|
|
console.log('\ntasks表结构:');
|
||
|
|
rows.forEach(row => {
|
||
|
|
console.log(row.name + ' (' + row.type + ')');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|