简体   繁体   English

如何使用 appscripts 连接到运行在云服务器上的 mysql 或 postgresql 数据库?

[英]How to connect to mysql or postgresql database running on a cloud server with appscripts?

I am trying to connect to a postgresql server, which is currently running on a google cloud machine with appscripts .我正在尝试连接到postgresql服务器,该服务器当前在带有appscriptsgoogle cloud machine上运行。 I want to push the data from the google spreadsheet to that postgresql database, I have tried to achieve this with the help of jdbc documentation provided in this documentation .我想将谷歌电子表格中的数据推送到 postgresql 数据库,我试图在本文档中提供的jdbc文档的帮助下实现这一点。 I have gone through the documentation but couldn't find anything related to postgresql, so i tried connecting with mysql database running on the same server but it is showing the error我浏览了文档,但找不到与 postgresql 相关的任何内容,所以我尝试连接在同一台服务器上运行的 mysql 数据库,但它显示错误

在此处输入图像描述 The code which I tried for connecting to mysql looks like我尝试连接到 mysql 的代码看起来像

var server = 'ipaddress'
var dbName = 'dbname'
var username = 'db name'
var password = 'password'
var port = 3306
var url = 'jdbc:mysql://' + server + ":" + port + "/" + dbName;
function myFunction() {
  var conn = Jdbc.getConnection(url, username, password)
  Logger.log(url);
  Logger.log(conn);
  conn.close();
}

My current code for postgresql looks like我当前的 postgresql 代码看起来像

var dbName = 'dbname'
var username = 'username'
var password = 'password'
var port = 5432
function myFunction() {
  var url = 'jdbc:postgresql://' + server + ":" + port + "/" + dbName;
  var conn = Jdbc.getConnection(url, username, password)
  Logger.log(url);
  Logger.log(conn);
  conn.close();
}

I am getting the error我收到错误

在此处输入图像描述

How to solve this?如何解决这个问题? and is it even possible to connect to postgresql with appscripts?甚至可以使用 appscripts 连接到 postgresql 吗? PS I am able to connect to the same database with same credentials with pgadmin PS 我可以使用 pgadmin 使用相同的凭据连接到同一个数据库

From Apps Script documentation here :来自此处的Apps 脚本文档:

The JDBC service supports Google Cloud SQL MySQL, MySQL, Microsoft SQL Server, and Oracle databases. The JDBC service supports Google Cloud SQL MySQL, MySQL, Microsoft SQL Server, and Oracle databases.

So PostgreSQL is not yet supported.所以 PostgreSQL 还不支持。

For the MySQL connection, from the error message, it is clear that your credentials seems wrong.对于 MySQL 连接,从错误消息中可以清楚地看出您的凭据似乎错误。 Check it by login to your database remote server via terminal通过终端登录到您的数据库远程服务器来检查它

mysql -u <username> -p -h <ip_address>

or connect it via Database Tools like DBeaver或通过DBeaver等数据库工具连接它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将MySQL数据库与Cloud JIRA数据库连接? - How can I connect my MySQL database with Cloud JIRA Database? 如何将MySQL客户端与Docker中运行的服务器连接 - How to connect MySQL client with server running in Docker 如何连接到在虚拟机上运行的MySQL服务器 - How to connect to a MySQL server running on a Virtual Machine 连接到谷歌云 MySQL 数据库 - Connect to Google Cloud MySQL Database 如何在外部托管服务器上将android应用程序连接到正在运行的MySQL数据库 - How do I Connect an android application to a running MySQL Database, on an external hosted server 如何使用 SSL 从本地主机上的 node.js 连接到运行在 PlanetScale 上的 MySQL 数据库服务器? - How do I connect to a MySQL database server running on PlanetScale with SSL from node.js on localhost? 如何将django开发者服务器连接到MySQL数据库? - How to connect django developer server to MySQL database? 如何通过php连接其他服务器的mysql数据库 - How connect with mysql database in other server by php 如何将我的应用程序与 MySQL 数据库作为 oracle 云基础设施上的服务连接? - How to connect my application with MySQL database as a service on oracle cloud infrastructure? 如何使用 DataGrip 连接到 Google Cloud MySQL 数据库? - How do I connect to a Google Cloud MySQL database using DataGrip?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM