当主机不是本地主机时,PostgreSQL连接字符串(URL postgres://…)是什么格式?
这里是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;
下面的方法对我很有效
const conString = "postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName";
server.address=10.20.20.10
server.port=8080
database.user=username
database.password=password
spring.datasource.url=jdbc:postgresql://${server.address}/${server.port}?user=${database.user}&password=${database.password}
还可以通过编程方式从工作的DB连接器检索连接字符串。
例如,我有时从SQLAlchemy的引擎中提取连接字符串,如下所示:
> db_engine.url
postgres://{user}:{password}@{host}:{port}/{db_name}?sslmode=require
有些人似乎误读了数据库名作为服务器名和主机作为postgresql服务器?主机上有一个postgresql服务器,该服务器上有一个数据库。还是我遗漏了什么?
postgresql: / / my_host及服务器= my_postgresql_server ?用户= my_user&port = my_port&password = my_password&database = my_database
例子:
My_host:可以是“localhost”(但这不在问题中)或主机的IP地址。
postgresql: / / my_host / &server = postgres ?用户= postgres&port 5432&password = postgres&database = test_db
为我工作在Python sqlalchemy和postgresql localhost运行。需要sqlalchemy、postgresql和psycopg2才能使其工作。
PS:这个问题是关于postgres的://…URL,但这在这里不起作用。相反,你需要postgresql,在Python中最后运行的是方言+驱动程序(参见数据库url) = postgresql+psycopg2,而不必像这样编写。
推荐文章
- 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表?