Javascript 使用NodeJS连接到postgresql时出错

Javascript 使用NodeJS连接到postgresql时出错,javascript,node.js,postgresql,pg-promise,Javascript,Node.js,Postgresql,Pg Promise,我正在尝试连接到postgresql数据库,目的是从数据库中的一些表中检索数据 我在编写代码时遵循了,尝试使用连接字符串和配置对象进行连接,但最终出现以下错误 (node:30315) UnhandledPromiseRejectionWarning: error: database " /dw" does not exist at Connection.parseE (/Users/swagnikdutta/Desktop/Rupeek/db-crawler/node_modules/pg/l

我正在尝试连接到postgresql数据库,目的是从数据库中的一些表中检索数据

我在编写代码时遵循了,尝试使用连接字符串和配置对象进行连接,但最终出现以下错误

(node:30315) UnhandledPromiseRejectionWarning: error: database " /dw" does not exist
at Connection.parseE (/Users/swagnikdutta/Desktop/Rupeek/db-crawler/node_modules/pg/lib/connection.js:606:11)
at Connection.parseMessage (/Users/swagnikdutta/Desktop/Rupeek/db-crawler/node_modules/pg/lib/connection.js:403:19)
at Socket.<anonymous> (/Users/swagnikdutta/Desktop/Rupeek/db-crawler/node_modules/pg/lib/connection.js:123:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
我查找了类似的问题,但找不到解释为什么会发生这种情况的解决方案。任何帮助都将不胜感激

谢谢

编辑:添加了连接字符串

postgresql://<username>:<userpassword>@datawarehouse.gcbewejpbwvm.ap-south-1.rds.amazonaws.com%20/dw?statusColor=323232&enviroment=local&name=dw&tLSMode=0&usePrivateKey=false&safeModeLevel=0&advancedSafeModeLevel=0
postgresql://:@datawarehouse.gcbewejpbwvm.ap-south-1.rds.amazonaws.com%20/dw?statusColor=323232&environment=local&name=dw&tLSMode=0&usePrivateKey=false&safeModeLevel=0&advancedSafeModeLevel=0

您的连接字符串在哪里它说它找不到连接字符串中指定的数据库读取错误
错误:数据库“/dw”不存在
似乎在/dw之前有额外的空间。如果看不到实际的连接字符串,我们就不能再多说了。
com%20/dw
%20是一个编码的空格符号。为什么在那里?我在问题中添加了连接字符串@StephaneM我之前注意到了奇怪的空格,这就是为什么我将字符串转换成一个对象。在对象中,我使用
connectionConfig.database=connectionConfig.database.slice(1)
删除了空间,但仍然发生了错误。