当主机不是本地主机时,PostgreSQL连接字符串(URL postgres://…)是什么格式?
当前回答
下面的方法对我很有效
const conString = "postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName";
其他回答
这里是JDBC的文档,一般的URL是" JDBC:postgresql://host:port/database"
这里的第3章记录了ADO。NET连接字符串, 一般连接字符串是Server=host;Port=5432;User Id=username;Password=secret;
PHP文档我们这里,一般的连接字符串是 Host =hostname port=5432 dbname=databasename user=username password=secret
如果你用了别的药,你得告诉我们。
如果对各自的语言使用Libpq绑定,根据其文档,URI的形式如下:
postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
以下是来自同一文档的示例
postgresql://
postgresql://localhost
postgresql://localhost:5432
postgresql://localhost/mydb
postgresql://user@localhost
postgresql://user:secret@localhost
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://localhost/mydb?user=other&password=secret
postgres的连接url 语法:
"Server=host ipaddress;Port=5432;Database=dbname;User Id=userid;Password=password;
例子:
"Server=192.168.1.163;Port=5432;Database=postgres;User Id=postgres;Password=root;
还可以通过编程方式从工作的DB连接器检索连接字符串。
例如,我有时从SQLAlchemy的引擎中提取连接字符串,如下所示:
> db_engine.url
postgres://{user}:{password}@{host}:{port}/{db_name}?sslmode=require
下面的方法对我很有效
const conString = "postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName";
推荐文章
- PostgreSQL删除所有内容
- 为什么PostgreSQL要对索引列进行顺序扫描?
- PostgreSQL INSERT ON冲突更新(upsert)使用所有排除的值
- 如何检查一个表是否存在于给定的模式中
- 如何将整数转换为字符串作为PostgreSQL查询的一部分?
- Psycopg2:用一个查询插入多行
- PostgreSQL返回JSON数组的结果集?
- PostgreSQL通配符LIKE用于单词列表中的任何一个
- 检查Postgres JSON数组是否包含字符串
- psql: FATAL: Peer authentication failed for user "dev"
- 如何在Postgres/SQL中获得两个整数的最小/最大值?
- 如何在postgresql中显示函数,过程,触发器源代码?
- 如何用postgres将间隔转换为小时数?
- 在postgresql中将查询结果按月和年分组
- 如何改变一个列的数据类型在PostgreSQL表?