import-data.js 569 B

1234567891011121314151617181920
  1. const pgp = require('pg-promise')();
  2. const fs = require('fs');
  3. // 连接到数据库
  4. import {pgClient} from "../../db/pg-instance"
  5. import {initDataSQL} from "../data/init-data.sql"
  6. // 执行SELECT语句并返回结果的函数
  7. export async function importData() {
  8. console.log("加载初始化数据")
  9. try {
  10. // 查询:数据库版本信息
  11. const data = await pgClient().any(initDataSQL);
  12. console.log(data)
  13. return data;
  14. } catch (error) {
  15. console.error('Error executing query:', error);
  16. return null;
  17. }
  18. }