check-python-config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import mysql from 'mysql2/promise';
  2. async function checkConfig() {
  3. const connection = await mysql.createConnection({
  4. host: '8.136.223.156',
  5. port: 6630,
  6. user: 'media_manager',
  7. password: 'media_manager',
  8. database: 'media_manager'
  9. });
  10. try {
  11. // 检查 system_config 表
  12. const [rows] = await connection.execute(
  13. 'SELECT * FROM system_config WHERE config_key = "python_publish_service_url"'
  14. );
  15. console.log('system_config 表中的 Python 服务配置:');
  16. console.log(rows);
  17. // 检查用户是否设置了配置
  18. if (rows.length === 0) {
  19. console.log('数据库中没有找到 python_publish_service_url 配置');
  20. // 插入默认配置
  21. await connection.execute(
  22. 'INSERT INTO system_config (config_key, config_value, description) VALUES (?, ?, ?)',
  23. ['python_publish_service_url', 'http://47.96.25.207:5005', 'Python 发布服务地址']
  24. );
  25. console.log('已插入默认配置: http://47.96.25.207:5005');
  26. }
  27. } catch (error) {
  28. console.error('数据库查询错误:', error.message);
  29. } finally {
  30. await connection.end();
  31. }
  32. }
  33. checkConfig();