44 lines
1.6 KiB
JavaScript
44 lines
1.6 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数据库连接成功');
|
||
|
|
insertCustomerData();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// 插入测试客户数据
|
||
|
|
function insertCustomerData() {
|
||
|
|
console.log('开始插入测试客户数据...');
|
||
|
|
|
||
|
|
// 插入测试客户
|
||
|
|
const customers = [
|
||
|
|
['客户A', '张三', '总经理', '13800138001', 'zhangsan@customerA.com', '北京市朝阳区', '重要客户'],
|
||
|
|
['客户B', '李四', '财务总监', '13800138002', 'lisi@customerB.com', '上海市浦东新区', '长期合作'],
|
||
|
|
['客户C', '王五', '项目经理', '13800138003', 'wangwu@customerC.com', '广州市天河区', '新客户'],
|
||
|
|
['客户D', '赵六', '技术总监', '13800138004', 'zhaoliu@customerD.com', '深圳市南山区', '战略伙伴'],
|
||
|
|
['客户E', '钱七', '采购经理', '13800138005', 'qianqi@customerE.com', '杭州市西湖区', '潜在客户']
|
||
|
|
];
|
||
|
|
|
||
|
|
customers.forEach(customer => {
|
||
|
|
db.run(
|
||
|
|
'INSERT INTO customers (name, contact, position, phone, email, address, remark) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||
|
|
customer,
|
||
|
|
(err) => {
|
||
|
|
if (err) {
|
||
|
|
console.error('插入客户数据失败:', err.message);
|
||
|
|
} else {
|
||
|
|
console.log('插入客户数据成功:', customer[0]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
console.log('测试客户数据插入完成');
|
||
|
|
}
|