WMS_MAIN/scripts/check_tables.js

32 lines
1.2 KiB
JavaScript

'use strict';
const mysql = require('mysql2/promise');
(async () => {
const conn = await mysql.createConnection({ host: '127.0.0.1', port: 3307, user: 'wms', password: 'dspxmRwRdRbWtbm7', database: 'wms' });
const [ tables ] = await conn.query("SHOW TABLES LIKE 'wms_order_delivery%'");
console.log('order_delivery tables:');
tables.forEach(t => console.log(' ', Object.values(t)[0]));
const [ tables2 ] = await conn.query("SHOW TABLES LIKE '%recheck%'");
console.log('recheck tables:');
tables2.forEach(t => console.log(' ', Object.values(t)[0]));
const [ tables3 ] = await conn.query("SHOW TABLES LIKE '%wave%'");
console.log('wave tables:');
tables3.forEach(t => console.log(' ', Object.values(t)[0]));
// Check the current model table for warehouse 100000
console.log('\nChecking wms_order_delivery for recheck_status:');
try {
const [ rows ] = await conn.query('SELECT * FROM wms_order_delivery WHERE warehouse_id = 100000 LIMIT 1');
if (rows.length > 0) {
console.log('Keys:', Object.keys(rows[0]).join(', '));
}
} catch (e) {
console.log('Error:', e.message);
}
await conn.end();
})().catch(e => console.error(e.message));