x-devapi无法连接到google app engine中的数据库

fquxozlt  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(281)

我正在部署一个简单的 nodejs 服务器到应用程序引擎,除了使用 X-devapi . 我得到这个错误: All routers failed. 以下是我使用的代码:

'use strict';

const express = require('express');
const mysqlx = require('@mysql/xdevapi');

const app = express();
app.get('/', (req, res) => {
  const options = { user: 'user_name', password: '@pass',host: 'XX.XXX.XX.XXX'
/*Here I used Public IP address on the of the SQL instance*/,port: XXXX
/*I assigned port 8080 here*/, schema: 'db_name' };

(async function () {
  let session;

  try {
    session = await mysqlx.getSession(options);

    const collection = await session.getSchema(options.schema).createCollection('collection');
    await collection.add({ name: 'foo' }).execute();
    await collection.find().fields('name').execute(console.log); // { name: 'foo' }
  } catch (err) {
    //console.error(err.message);
    res.status(200).send(err.message).end();//used code 200 in order to receive the error too
  } finally {
    session && session.close();
  }
})();
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

我怎样才能解决这个问题?

g52tjvyc

g52tjvyc1#

事实证明,google云sql工具仍然没有 X devAPI 如果您在此处检查对我的问题的响应和功能请求,则启用此选项

相关问题